Install MySQL at WSL: Difference between revisions
From WikiMLT
m Стадий: 4 [Фаза:Авторизиране, Статус:Разработен]; Категория:Databases |
m Стадий: 5 [Фаза:Утвърждаване, Статус:Авторизиран]; Категория:Databases |
||
Line 60: | Line 60: | ||
{{devStage | {{devStage | ||
| Прндл = Databases | | Прндл = Databases | ||
| Стадий = | | Стадий = 5 | ||
| Фаза = | | Фаза = Утвърждаване | ||
| Статус = | | Статус = Авторизиран | ||
| ИдтПт = Spas | | ИдтПт = Spas | ||
| РзбПт = Spas | | РзбПт = Spas | ||
| АвтПт = {{REVISIONUSER}} | | АвтПт = Spas | ||
| УтвПт = {{REVISIONUSER}} | |||
| ИдтДт = 12.02.2023 | | ИдтДт = 12.02.2023 | ||
| РзбДт = 12.02.2023 | | РзбДт = 12.02.2023 | ||
| АвтДт = {{Today}} | | АвтДт = 12.02.2023 | ||
| УтвДт = {{Today}} | |||
| ИдтРв = [[Special:Permalink/32228|32228]] | | ИдтРв = [[Special:Permalink/32228|32228]] | ||
| РзбРв = [[Special:Permalink/32231|32231]] | | РзбРв = [[Special:Permalink/32231|32231]] | ||
| АвтРв = {{REVISIONID}} | | АвтРв = [[Special:Permalink/32232|32232]] | ||
| УтвРв = {{REVISIONID}} | |||
}} | }} | ||
</div> | </div> | ||
</noinclude> | </noinclude> |
Revision as of 10:47, 12 February 2023
Install mysql-server
and mysql-client
.
sudo apt install -y mysql-client mysql-server
sudo service mysql start
sudo service mysql status
mysql --version
Then create a MySQL user that is able to log-in into the MySQL server by using native authentication. Gran to the user all privileges.
sudo mysql
CREATE USER 'local_admin'@'localhost' IDENTIFIED WITH mysql_native_password BY 'local_admin_password_1!2@3#';
GRANT ALL PRIVILEGES ON *.* TO 'local_admin'@'localhost' WITH GRANT OPTION;
SELECT user,plugin,host FROM mysql.user WHERE host = 'localhost';
+------------------+-----------------------+-----------+
| user | plugin | host |
+------------------+-----------------------+-----------+
| debian-sys-maint | caching_sha2_password | localhost |
| local_admin | mysql_native_password | localhost |
| mysql.infoschema | caching_sha2_password | localhost |
| mysql.session | caching_sha2_password | localhost |
| mysql.sys | caching_sha2_password | localhost |
| root | auth_socket | localhost |
+------------------+-----------------------+-----------+
6 rows in set (0.00 sec)
quit
Now log-in by that user in order to test it and create one new empty data base for the further tests.
mysql -u'local_admin' -p'local_admin_password_1!2@3#'
CREATE DATABASE nodejs_w3s_tests;
Query OK, 1 row affected (0.01 sec)
quit
In order to start the MySQL server automatically at user log-in, create or update the file wsl-services.bat
, located in the Windows user's folder shell:startup
, with the following entry.
wsl-services.bat
C:\Windows\System32\wsl.exe -u root /etc/init.d/mysql start
References:
- Open Ubuntu terminal using batch file on windows with command?
- Ubuntu 18.04 on WSL Cron daemon not running after reboot