Glam Prestige Journal

Bright entertainment trends with youth appeal.

I tried installing MySQL on my machine (sudo apt-get install mysql-server) but after installation I cannot get it to run. When I enter mysql or mysql -u root command I receive the error ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock.

I tried following the tutorials online and I noticed that I'm not asked to created a password during installation as mentioned online. I had a lamp stack before which I got rid of. I'm now reinstalling MySQL which I want to use for web development (JavaEE/Spring). Can anybody shed some light on what I'm doing wrong?

2

3 Answers

Please go through with following steps

sudo apt-get install mysql-server
sudo mysql_secure_installation

You need to check MySQL servics running or not.

 sudo service mysql start

Check status by executing

sudo service mysql status

Then then

 mysql

Or check which port used during instllation

 mysql -h localhost --port 3306 - u root -p

you can also use MySQLTuner by executing:

 sudo apt-get install mysqltuner
1

You can refer the MySQL official documentation here

1

It's very simple to install mysql on ubuntu , just follow these steps to properly install mysql :

Step 1 : update the system

sudo apt update

Step 2 : Install mysql package

sudo apt install mysql-server

Step 3 : Once the installation is completed, the MySQL service will start automatically. To check whether the MySQL server is running, type:

sudo systemctl status mysql

The output of the following command should be :

OUTPUT
mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2018-06-20 11:30:23 PDT; 5min ago
Main PID: 17382 (mysqld) Tasks: 27 (limit: 2321)
CGroup: / `-17382 /usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid 

Step 4 : Securing MySQL

sudo mysql_secure_installation

select one of the three levels of password validation policy(strong recommended).Set your password ,and then type y(yes) to all the questions , this will improve the security .

Step 5 : Once it has done. open MySQL by typing the following command :

sudo mysql

Step 6 : If you want to login to your MySQL server as root from an external program such as phpMyAdmin , then type these commands inside mysql.

mysql>ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'strong_password';
mysql>FLUSH PRIVILEGES;
mysql>exit;

After this you will be successfully able to run mysql , for this open terminal and type.

mysql -u root -p

Now type your password.

Congo! you are done with installing mysql.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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