Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install mysql-server in Ubuntu

I have mariadb in my ubuntu system but it is not working properly , so i want to again install mysql in my system .

For Remove mariadb i have run these commands .

  1. sudo apt-get --purge remove "mysql*"

  2. sudo mv /etc/mysql/ /tmp/mysql_configs/

  3. nano /etc/apt/sources.list

  4. sudo apt-get update

  5. sudo apt-get install mysql-server-5.6

but after step 5 it's give me these errors :

Reading package lists... Done Building dependency tree
Reading state information... Done You might want to run 'apt-get -f install' to correct these: The following packages have unmet dependencies: libmysqlclient18 : Depends: mysql-common (= 5.6.30-1ubuntu14.04) mariadb-server-5.5 : Breaks: mysql-server-5.6 Breaks: virtual-mysql-server mariadb-server-core-5.5 : Conflicts: mysql-server-5.6 mysql-server-5.6 : Depends: mysql-client-5.6 (>= 5.6.30-0ubuntu0.14.04.1) Depends: mysql-server-core-5.6 (= 5.6.30-0ubuntu0.14.04.1) Recommends: mysql-common-5.6 but it is not going to be installed Breaks: virtual-mysql-server W: Duplicate sources.list entry http://debian.datastax.com/community/ stable/main amd64 Packages (/var/lib/apt/lists/debian.datastax.com_community_dists_stable_main_binary-amd64_Packages) W: Duplicate sources.list entry http://debian.datastax.com/community/ stable/main i386 Packages (/var/lib/apt/lists/debian.datastax.com_community_dists_stable_main_binary-i386_Packages) W: You may want to run apt-get update to correct these problems E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

Can anyone give me suggestion how can i install mysql in my system . Thanks in advance .

like image 666
Anuj Dhiman Avatar asked Sep 06 '25 03:09

Anuj Dhiman


2 Answers

First of all, you need to update the system.

sudo apt update && upgrade

then perform the MySQL installation commands and follow the instructions.

sudo apt install mysql-server
sudo mysql_secure_installation

Once it has done. try to open MySQL.

sudo mysql

try to check the authentication method each of your MySQL user accounts uses with the following command in the MySQL terminal:

SELECT user,authentication_string,plugin,host FROM mysql.user;

this will return users with authentication_string. Change the MySQL root password with the following command.

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';

FLUSH PRIVILEGES;

Flush Privileges which tells the server to reload the grant tables and put your new changes into effect

like image 69
Girish Vas Avatar answered Sep 07 '25 21:09

Girish Vas


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

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: /system.slice/mysql.service
       `-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.

like image 31
vishwampandya Avatar answered Sep 07 '25 19:09

vishwampandya