mysql初始化root 密码是多少_Mysql初始化root密码和允许远程访问

mysql默认root用户没有密码,输入mysql –u root 进入mysql

1、初始化root密码

进入mysql数据库

mysql>update user set password=PASSWORD('123456') where User='root';

2、允许mysql远程访问,有以下几中方式

如果不允许远程访问,会报如下的错误:

ERROR 1130 (HY000): Host ‘1.2.3.4’ is not allowed to connect to this MySQL server

(1)、Change mysql config

vim /etc/mysql/my.cnf

Comment out following lines.

#bind-address = 127.0.0.1#skip-networking

If you do not find skip-networking line, add it and comment out it.

Restart mysql server.

/etc/init.d/mysql restart

(2)、Change GRANT privilege

Run a command like below to access from all machines. (Replace USERNAME and PASSWORD by your credentials.)

mysql> GRANT ALL PRIVILEGES ON *.* TO 'USERNAME'@'%' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;

Run a command like below to give access from specific IP. (Replace USERNAME and PASSWORD by your credentials.)

mysql> GRANT ALL PRIVILEGES ON *.* TO 'USERNAME'@'1.2.3.4' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;

Finally, you may also need to run:

mysql> FLUSH PRIVILEGES;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值