INSTALASI MYSQL-5.7 LINUX

6 Juli 2018

A. Proses Instalasi
$ sudo apt install mysql-server mysql-client mysql-common

B. Proses Konfigurasi
Kalau kita langsung mencoba login menggunakan root akan gagal dengan error kurang lebih sebagai berikut
juwarto@DJOE:~$ mysql -u root
ERROR 1698 (28000): Access denied for user ‘root’@’localhost’
juwarto@DJOE:~$ mysql -u root -p
Enter password:
ERROR 1698 (28000): Access denied for user ‘root’@’localhost’

Kegagalan tersebut terjadi karena mysql secara default menggunakan UNIX auth_socket plugin.

Solusinya adalah dengan langkah-langkah berikut:

$ sudo mysql -u root

mysql> USE mysql;
mysql> SELECT User, Host, plugin FROM mysql.user;

+——————+———————–+
| User | plugin |
+——————+———————–+
| root | auth_socket |
| mysql.sys | mysql_native_password |
| debian-sys-maint | mysql_native_password |
+——————+———————–+

Seperti yang terlihat pada hasil query, user root menggunakan auth_socket plugin

Ada 2 cara untuk memecahkan masalah ini:
a. You can set the root user to use the mysql_native_password plugin
b. You can create a new db_user with you system_user (recommended)

Option 1:

$ sudo mysql -u root # I had to use “sudo” since is new installation

mysql> USE mysql;
mysql> UPDATE user SET plugin=’mysql_native_password’ WHERE User=’root’;
mysql> FLUSH PRIVILEGES;
mysql> exit;

$ service mysql restart

Option 2: (replace YOUR_SYSTEM_USER with the username you have)

$ sudo mysql -u root # I had to use “sudo” since is new installation

mysql> USE mysql;
mysql> CREATE USER ‘YOUR_SYSTEM_USER’@’localhost’ IDENTIFIED BY ‘YOUR_SYSTEM_PASSWORD’;
mysql> GRANT ALL PRIVILEGES ON *.* TO ‘YOUR_SYSTEM_USER’@’localhost’;
mysql> UPDATE user SET plugin=’auth_socket’ WHERE User=’YOUR_SYSTEM_USER’;
mysql> FLUSH PRIVILEGES;
mysql> exit;

$ service mysql restart

Remember that if you use option #2 you’ll have to connect to mysql as your system username (mysql -u YOUR_SYSTEM_USER)

Note: On some systems (e.g., Debian stretch) ‘auth_socket’ plugin is called ‘unix_socket’, so the corresponding SQL command should be: UPDATE user SET plugin=’unix_socket’ WHERE User=’YOUR_SYSTEM_USER’;

Sumber:
https[:]//stackoverflow[.]com/questions/39281594/error-1698-28000-access-denied-for-user-rootlocalhost

Tidak ada Komentar

Tinggalkan Balasan

Alamat email Anda tidak akan dipublikasikan. Ruas yang wajib ditandai *

This site uses Akismet to reduce spam. Learn how your comment data is processed.