CentOS 7的yum源中貌似沒有正常安裝mysql時的mysql-sever文件,需要去官網上下載
# wgethttp://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm # rpm -ivh mysql-community-release-el7-5.noarch.rpm
# yum install mysql-community-server
成功安裝之後重啟mysql服務
# service mysqld restart
初次安裝mysql是root賬戶是沒有密碼的
設置密碼的方法
# mysql -uroot
mysql> set password for ‘root’@‘localhost’ = password('mypasswd');
mysql> exit
mysql授權
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost'
-> IDENTIFIED BY 'some_pass' WITH GRANTOPTION;
首先要聲明一下:一般情況下,修改MySQL密碼,授權,是需要有mysql裡的root權限的。
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
搞定!