1.Installing MySQL
$ sudo apt update
$ sudo apt install mysql-server
2.Configuring MySQL
$ sudo mysql_secure_installation
3.Adjusting User Authentication and Privileges
$ mysql -u root -p mysql> GRANT ALL ON *.* TO 'sammy'@'localhost' IDENTIFIED BY 'password'; mysql> FLUSH PRIVILEGES;
4.Testing MySQL
$ systemctl status mysql.service ● mysql.service - MySQL Community Server Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled) Active: active (running) since Thu 2020-02-06 15:32:25 +07; 17min ago Main PID: 3831 (mysqld) Tasks: 28 (limit: 4915) CGroup: /system.slice/mysql.service └─3831 /usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid
ถ้า mysql ไม่ start ให้ start ด้วย
$ sudo systemctl start mysql
ดูเวอร์ชันของ mysqladmin
$ sudo mysqladmin -p -u root version Enter password: mysqladmin Ver 8.42 Distrib 5.7.29, for Linux on x86_64 Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Server version 5.7.29-0ubuntu0.18.04.1 Protocol version 10 Connection Localhost via UNIX socket UNIX socket /var/run/mysqld/mysqld.sock Uptime: 18 min 31 sec Threads: 1 Questions: 21 Slow queries: 0 Opens: 113 Flush tables: 1 Open tables: 106 Queries per second avg: 0.018