MySQL is an open-source database management system, commonly installed as part of the popular LAMP(Linux, Apache, MySQL, PHP/Python/Perl) stack. It uses a relational database and SQL (Structured Query Language) to manage its data.
You need to first update your package index, install the mysql-serverpackage, and then run the included security and database initialization scripts.
sudo apt-get update
sudo apt-get install mysql-server
To install MySQL 5.6, install the mysql-server-5.6 package,
sudo apt-get install mysql-server-5.6
Hit y and continue..
Enter a password for the root user and Click OK
Re-enter the password and click OK
Note: Mysql “root” account should have a password. Else anyone with an account on your machine will get full access to the database.
In MySQL 5.6, you might get an error like FATAL ERROR: Could not find my-default.cnf. In this case copy the /usr/share/my.cnf configuration file into the location that mysql_install_db expects, then rerun it.
sudo cp /etc/mysql/my.cnf /usr/share/mysql/my-default.cnf
Again try this command
This is due to some changes made in MySQL 5.6 and a minor error in the APT package.
You can check your version of MySQL with the following command.
mysql –version (OR) mysql -u root
If you get an error message saying Access denied for user..
That is the normal behavior. You have set a root password for your database so from now on you can’t access it without password. Try the following command.
mysql -u root -p
MySQL should start running automatically after installation. To test this, check its status.
service mysql status
If MySQL isn’t running, you can start it with the following command
sudo service mysql start
You can try connecting to the database using the mysqladmin tool, which is a client that lets you run administrative commands. For example, this command says to connect to MySQL as root (-u root), prompt for a password (-p), and return the version.
mysqladmin -p -u root version