1. Instalación
$ sudo apt actualización
$ sudo apt instalar servidor mysql
2. Configurar mysql
$ sudo mysql_secure_installation
El primero es establecer la contraseña del usuario root :
Después de configurar correctamente la contraseña de root , habrá una serie de configuraciones de seguridad:
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 la instalación de mysql :
$ systemctl estado mysql.service
4, usando el comando root y la contraseña para iniciar sesión y configurar 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;
Error:
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
Ejecute sql:
seleccione usuario, host, contraseña de mysql.user;
Ejecute sql:
ALTER USUARIO 'root' @ 'localhost' IDENTIFICADO POR '_huitao' ;
Actualizar
PRIVILEGIOS DE FLUSH;
Cambiar parámetros:
Tenga en cuenta que 8.0 tiene más variables con "." Que 5.7, por lo que establecer la mitad no es suficiente
establecer global validate_password.policy = 0;
establecer global validate_password.length = 4;
Luego sal y luego ejecuta
mysql_secure_installation
actualizar el conjunto de usuarios plugin = "mysql_native_password", authentication_string = contraseña ('设置 的 密码') donde usuario = "root";
Actualizar permisos
DESCARGAR PRIVILEGIOS;
Navica no puede conectarse a la solución de base de datos:
1. Utilice la siguiente declaración para ver el modo de cifrado actual de MySQL
seleccione host, usuario, complemento del usuario;
Mire la primera línea, el método de cifrado raíz es caching_sha2_password.
2. Utilice el comando para modificarlo al modo de cifrado mysql_native_password:
actualizar el conjunto de usuarios plugin = 'mysql_native_password' donde usuario = 'root';
Navica se conecta a la base de datos: