2
votes

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 .

5
Did you run 'apt-get -f install' as suggested by the output?ADyson
@ADyson yes i have run that command but i did not get any positive result .Anuj Dhiman
what result did you get?ADyson
dpkg: error processing archive /var/cache/apt/archives/mysql-common_5.6.30-1ubuntu14.04_amd64.deb (--unpack): trying to overwrite '/usr/share/mysql/slovak/errmsg.sys', which is also in package mariadb-server-core-5.5 5.5.47-1ubuntu0.14.04.1 dpkg-deb: error: subprocess paste was killed by signal (Broken pipe) Errors were encountered while processing: /var/cache/apt/archives/mysql-common_5.6.30-1ubuntu14.04_amd64.deb E: Sub-process /usr/bin/dpkg returned an error code (1)Anuj Dhiman
have you tried attempting to purge the mariadb-server package instead?ADyson

5 Answers

3
votes

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

3
votes

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.

0
votes

Lesson from continuous deployment test. You MUST do this purge mysql-common. You CANNOT put mariadb and mysql in the same system, they want their own mysql-common and not sharing them. Which many other API wrapped around it to connect to those server.

And you must comment all the repo pointing to mariadb. Otherwise it will install the same version again from mariadb.

sudo apt-get purge mysql-common
# Put back the mysql-common , make sure you use the new mysql repo,
# remarks mariadb repo
sudo apt-get install software-properties-common

Always check whether any OTHER file or folder contains mariadb repo.

cd /etc/apt
fgrep -lR "maria" 
0
votes

The easy way for this is installing the synaptic package manager by typing the following command in the terminal:

sudo apt-get install synaptic

And then open synaptic by:

sudo synaptic

Then search for the package you have installed, mariadb, and mark it for complete removal and press apply.

And these commands to install mysql-server

sudo apt-get update
sudo apt-get install mysql-server
0
votes

It's quite easy to install mysql on Ubuntu.

sudo apt-get update
sudo apt-get install mysql-server

You'll be asked to create a new password for root user. Set a good password and you're ready to go.

You can also follow this youtube videos for installation and basic understanding for Mysql