1. 下载mysql的repo源
$ wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
2. 安装mysql-community-release-el7-5.noarch.rpm包
$ sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm
3. 安装mysql
$ sudo yum install mysql-server
问题1:
[wzh@centos-oracle ~]$ mysql -u root
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists!
[wzh@centos-oracle ~]$
【解决方法】
sudo chown -R wzh:wzh /var/lib/mysql
service mysqld restart
问题2
[wzh@centos-oracle ~]$ mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
【解决方法】
vi /etc/my.cnf
在mysqld下面添加skip-grant-tables
service mysqld restart
--
use mysql;
update user set password=password("mysql") where user="root";
flush privileges;
--密码重设置成功,改好之后,再修改一下my.ini这个文件,把我们刚才加入的"skip-grant-tables"这行删除,保存退出再重启mysql服务就可以了。