ubuntu 安装mysql

安装

sudo apt-get install mysql-server
sudo apt-get install mysql-client
sudo apt-get install libmysqlclient-dev

 

如果有问题,卸载

sudo apt-get remove mysql-server
sudo apt-get autoremove mysql-server
sudo apt-get remove mysql-common

远程访问

sudo gedit /etc/mysql/mysql.conf.d/mysqld.cnf

# bind-address          = 127.0.0.1

mysql远程访问权限

mysql> grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;

update user set host='%' where user='root' and host='localhost';

 

重启服务

sudo /etc/init.d/mysql restart

登录数据库

mysql -uroot -p123456

查看端口

➜  ~ netstat -an | grep 3306
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN 

 远程访问

mysql -h127.0.0.1 -uroot -p123456

 

posted @ 2017-10-12 11:11  永远的幻想  阅读(121)  评论(0编辑  收藏  举报