官方文档有写如何安装Mysql
$ apt update
$ apt install mysql-server mysql-client -y
$ service mysql start
mysql -uroot -p123456进入MySQL命令行
问题出在连接数据库这一步,命令行能进去,但是数据库插件和代码都连不上
Access denied for
大概率是权限和密码的问题,进入
mysql> use mysql
mysql> select user,host, authentication_string from user;
注意%虽然是匹配全部但是不匹配localhost,所以说要解决在Cloud Studio中本地连接报错需要给要用的账号给localhost的权限,以root为例,如果报错就drop一下
mysql> CREATE USER 'root'@'localhost' IDENTIFIED BY '12345678';
ERROR 1396 (HY000): Operation CREATE USER failed for 'root'@'localhost'
mysql> drop user root@'localhost';
Query OK, 0 rows affected (0.02 sec)
mysql> CREATE USER 'root'@'localhost' IDENTIFIED BY '12345678';
Query OK, 0 rows affected (0.01 sec)
mysql> grant all privileges on *.* to 'root'@'localhost';
在创建时如果报错ERROR 1819 (HY000),说明密码强度不满足要求,开发我们可以直接将密码强度设置成0
mysql> CREATE USER 'root'@'localhost' IDENTIFIED BY '12345678';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql> set global validate_password.policy=0;
Query OK, 0 rows affected (0.00 sec)
最后连接上了通过数据库插件连上了