首页 > 技术文章 > centos 6.5 安装mysql

lvlv 2015-09-24 01:04 原文

步骤1:

yum -y install mysql-server 

步骤2:

chkconfig mysqld on  

步骤3:

service mysqld start  
mysql -u root 
set password for root@localhost=password('root');  

登录mysql创建新用户:

create user 'test_user'@'%' identified by 'test_user';  

.给新用户test_user授权,让他可以从外部登陆和本地登陆
注意:@左边是用户名,右边是域名、IP和%,表示可以访问mysql的域名和IP,%表示外部任何地址都能访问。

grant all privileges on *.* to 'test_user'@'localhost' identified by 'test_user';
grant all privileges on *.* to 'test_user'@'%' identified by 'test_user';

 提示1130错误:

Sql代码
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;

执行完后,再
mysql:flush privileges; 

推荐阅读