运行一下命令安装mysql.
$ sudo apt-get install mysql-server
设置root密码:
$ sudo /etc/init.d/mysql reset-password
让root可以远程登陆:
登陆mysql控制台,然后运行:
mysql> use mysql;
mysql> update `user` set `host`="localhost" and `user`="root";
mysql> flush privileges;
修改/etc/mysql/my.cnf
$ sudo vi /etc/mysql/my.cnf
注释掉 bind-address = 127.0.0.1
#bind-address = 127.0.0.1
然后重启mysqld。
忘记root密码的处理办法:
默认会创建一个叫debian-sys-maint的用户,临时密码存在/etc/mysql/debian.cnf.取得临时密码,然后登陆mysql控制台:
$ mysql -udebian-sys-maint -p
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'abc123' WITH GRANT OPTION;
mysql> flush privileges;
$ sudo apt-get install mysql-server
设置root密码:
$ sudo /etc/init.d/mysql reset-password
让root可以远程登陆:
登陆mysql控制台,然后运行:
mysql> use mysql;
mysql> update `user` set `host`="localhost" and `user`="root";
mysql> flush privileges;
修改/etc/mysql/my.cnf
$ sudo vi /etc/mysql/my.cnf
注释掉 bind-address = 127.0.0.1
#bind-address = 127.0.0.1
然后重启mysqld。
忘记root密码的处理办法:
默认会创建一个叫debian-sys-maint的用户,临时密码存在/etc/mysql/debian.cnf.取得临时密码,然后登陆mysql控制台:
$ mysql -udebian-sys-maint -p
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'abc123' WITH GRANT OPTION;
mysql> flush privileges;