1. Instalação
$ sudo apt update
$ sudo apt install mysql-server
2. Configure o mysql
$ sudo mysql_secure_installation
A primeira é definir a senha do usuário root :
Depois de definir a senha root com sucesso , haverá uma série de configurações de segurança:
Remove anonymous users? (Press y|Y for Yes, any other key for No) : n
... skipping.
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
- Dropping test database...
Success.
- Removing privileges on test database...
Success.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.
All done!
3. Verifique a instalação do mysql :
$ systemctl status mysql.service
4, usando o comando root e a senha para fazer login apenas para definir o mysql go
1,登进MySQL之后,
$ sudo mysql -uroot –p
2,输入以下语句,进入mysql库:
use mysql
3,更新域属性,'%'表示允许外部访问:
update user set host='%' where user ='root';
4,执行以上语句之后再执行:
FLUSH PRIVILEGES;
5,再执行授权语句:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'WITH GRANT OPTION;
Erro:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'mysql_secure_installation
update user set host='localhost' where user ='root'' at line 1
Execute sql:
selecione usuário, host, senha de mysql.user;
Execute sql:
ALTER USER 'root' @ 'localhost' IDENTIFICADO POR '_huitao' ;
Atualizar
PRIVILÉGIOS DE FLUSH;
Altere os parâmetros:
Observe que 8.0 tem mais variáveis com "." Do que 5.7, portanto, definir metade dele não é suficiente
definir validate_password.policy = 0;
definir validate_password.length = 4 global;
Em seguida, saia e execute
mysql_secure_installation
update user set plugin = "mysql_native_password", authentication_string = password ('设置 的 密码') onde user = "root";
Atualizar permissões
FLUSH PRIVILEGES;
O Navica não consegue se conectar à solução de banco de dados:
1. Use a seguinte instrução para visualizar o modo de criptografia atual do MySQL
selecione host, usuário, plugin do usuário;
Observe a primeira linha, o método de criptografia raiz é caching_sha2_password.
2. Use o comando para modificá-lo para o modo de criptografia mysql_native_password:
update user set plugin = 'mysql_native_password' onde user = 'root';
O Navica se conecta ao banco de dados: