0

I never used Ubuntu, and now I installed Ubuntu 18.04, and I have a problem with connection to Database.

I'm not so familiar with the working with servers and things like that, so can anyone tell me what the problem is and how to fix it?

  • Are you able to start MySQL from terminal? – Kulfy Jun 25 '18 at 16:39
  • @Kulfy I only know to use this: service mysql status, it seems to work, and don't know what next nor how to fix it... – Simon Jun 25 '18 at 16:51
  • Try mysql -u root -p in terminal – Kulfy Jun 25 '18 at 16:54
  • @Kulfy it says: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) – Simon Jun 25 '18 at 16:55
  • It means you have provided wrong password and most probably in the given application too. – Kulfy Jun 25 '18 at 16:57
1

Check that your mysql server is running, if not enable it. From a terminal,

$ sudo systemctl enable mysql

Synchronizing state of mysql.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable mysql

$ sudo systemctl status mysql

● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2018-06-25 10:23:56 PDT; 56min ago
 Main PID: 1364 (mysqld)
    Tasks: 28 (limit: 4915)
   CGroup: /system.slice/mysql.service
           └─1364 /usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid

Check that you have it listen on port 3306.

$ sudo netstat -plunt

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      1364/mysqld   

If not, you'll have to modify /etc/mysql/mysql.conf.d/mysqld.cnf

Check that you have root access, enter password when prompted.

$ mysql -u root -p

If you don't have root access or need to reset root password, follow the steps from here. Which basically says the simplest way is do the following and choose a new root password.

$ sudo mysql_secure_installation

Securing the MySQL server deployment.

Enter password for user root: 

Now, if you want simply want to connect to a remote database, specify the host and port along with the login user/password when creating the mysql connection.

If you run into password validation problem, you may consider moving validate_password plugin

$ mysql -h localhost -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.7.22-0ubuntu18.04.1 (Ubuntu)

Copyright (c) 2000, 2018, 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.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> uninstall plugin validate_password;
| improve this answer | |
  • i came to "three levels of password validation policy...", what should i do there? and how to specify the host? Sorry, but this is the firs time i'm doing this – Simon Jun 25 '18 at 19:20
  • Looks like you ran into the same problem as I did when I upgraded to 18.04. I have to uninstall validate_password plugin so that I can use my password. Otherwise it kept complaining it is not secure enough password for "online" login. I'll add some instruction to remove the plugin. – Bernard Wei Jun 25 '18 at 23:34
  • Yes, I've heard from a lot of people that they have errors since they were upgraded to 18.04, okay, I am waiting for instructions – Simon Jun 26 '18 at 9:31
  • In 18.04, they enable the security feature to protect remote login, i.e., connecting via host and port. So you need to re-enable that in order to use mysql the old way, which is the way that workbench connect to the database. – Bernard Wei Jun 26 '18 at 17:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.