You can check whether MySQL is already installed by issuing the following command.
$ mysql -VYou should see something similar output as follows if you have MySQL installed.
mysql Ver 14.14 Distrib 5.5.32, for debian-linux-gnu (x86_64) using readline 6.2If not, to install MySQL, run the following command from a terminal prompt in apt-get package manager based Linux distributions
$ sudo apt-get install mysql-serverIn yum package manager based Linux distributions, issue the following command
$ sudo yum install mysql-serverYou will be prompted to enter a password for the MySQL root user in the installation process. It's recommended to use a password for a root account. Now the MySQL server is installed on your Linux machine.
Alternatively, you may download the relevant MySQL package (e.g. rpm package) for your Linux from http://dev.mysql.com/downloads/mysql/#downloads and install according to your distribution. You may need to sign up for an Oracle Web account to download from this site. This article won't go into details of installing with distribution specific packages.
MySQL installation could also be done with the source. You can also download the source distribution from the above URL. Installing from source needs certain tools and libraries pre-installed (such as cmake and ncurses-devel). Other workaround may be required to build from source.
To start the MySQL database, issue the following command.
$ sudo /etc/init.d/mysql startor in Fedora/RHEL
$ sudo systemctl start mysqld.serviceTo check whether MySQL is already running, you can issue the following command.
$ mysqladmin -u root -p statusYou will be prompted for the password. When entered, you should see somewhat similar output as follows if MySQL is running
Uptime: 28581 Threads: 1 Questions: 111 Slow queries: 0 Opens: 343 Flush tables: 1 Open tables: 84 Queries per second avg: 0.003If not running, you would see an output as shown below.
mysqladmin: connect to server at 'localhost' failed error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)' Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!You can edit the settings for the MySQL instance in /etc/mysql/my.cnf file to configure the basic settings like log file and port number.
That's it. You now should have MySQL installed on your system and ready to use it to develop database driven applications.
No comments:
Post a Comment