1.安装前,我们可以检测系统是否自带安装 MySQL:
>> rpm -qa | grep mysql
如果你系统有安装,那可以选择进行卸载:
>> rpm -e mysql // 普通删除模式
>> rpm -e --nodeps mysql // 强力删除模式,如果使用上面命令删除时,提示有依赖的其它文件,则用该命令可以对其进行强力删除
2.安装 MySQL
>> wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
>> rpm -ivh mysql-community-release-el7-5.noarch.rpm
>> yum update
>> yum install mysql-server
3.权限设置:
>> chown mysql:mysql -R /var/lib/mysql
4.初始化 MySQL:
>> mysqld --initialize
5.启动 MySQL:
>> systemctl start mysqld
>> systemctl stop mysqld
6.查看 MySQL 运行状态:
>> systemctl status mysqld
7.验证 MySQL 安装
>> mysqladmin --version
8.使用 MySQL Client(Mysql客户端) 执行简单的SQL命令
>> mysql
>> SHOW DATABASES;
9.Mysql安装后需要做的
>> mysqladmin -u root password "new_password";
>> mysql -u root -p
错误处理:
1.msg:Please read "Security" section of the manual to find out how to run mysqld as root
>> vim /etc/my.cfg 输入 user=mysql
2.msg:Access denied for user 'root'@'localhost' (using password: NO)
>> mysql -uroot -p 回车侯输入密码
3.远程连接失败的问题:
>> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '您的数据库密码' WITH GRANT OPTION;
>> flush privileges;