安装MySQL
sudo apt-get update
sudo apt-get install mysql-server
sudo apt-get install libmysqlclient-dev
登录 MySQL
mysql -u root -p
创建用户
REATE USER 'username'@'host' IDENTIFIED BY 'password';
进行授权用来远程连接
GRANT ALL PRIVILEGES ON *.* TO 'Ubuntu'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
删除授权
revoke insert,update,delete,select ON *.* from 'Ubuntu'@'%' IDENTIFIED BY '123456';
然后打开 vi /etc/mysql/mysql.conf.d/mysqld.cnf
将bind-address = 127.0.0.1
设置成bind-address = 0.0.0.0(设备地址)
腾讯云出现权限不够的问题:
http://bbs.qcloud.com/thread-11554-1-1.html
重新启动(命令如下):
/etc/init.d/mysql stop
/etc/init.d/mysql start
执行 flush privileges;命令立即生效
flush privileges;
查询数据库的用户(看到如下内容表示创建新用户成功了)
SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM mysql.user;
使用exit命令退出MySQL
exit