Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

MySQL installation


May 15, 2021 MySQL


Table of contents


MySQL installation

MySQL download address for all platforms is: MySQL download . Pick the version of MySQL Community Server you need and the corresponding platform.

Note: The installation process requires us to install by turning on administrator rights, otherwise we will not be able to install due to insufficient permissions.


MySQL is installed on Linux/UNIX

The RPM package is recommended on the Linux platform to install MySQL, and MySQL AB provides the download address for the following RPM packages:

  • MySQL - MySQL server. Select this option if you do not just want to connect to a MySQL server running on another machine.
  • MySQL-client - MySQL client program for connecting and operating Mysql servers.
  • MySQL-devel - Libraries and containing files, if you want to compile other MySQL clients such as perl modules, you need to install the RPM package.
  • MySQL-shared - This package contains a shared library (libmysqlclient.so) that some languages and applications need to dynamically mount, using MySQL.
  • MySQL-bench - Benchmarking and performance testing tool for MySQL database servers.

The following example of mySQL RMP is installed on a SuSE Linux system, and of course this installation step is appropriate for other Linux systems that support RPM, such as CentOS.


Before installation, we can detect if the system has mySQL installed with it:

rpm -qa | grep mysql

If your system has an installation, you can choose to uninstall it:

rpm -e mysql  // 普通删除模式
rpm -e --nodeps mysql  // 强力删除模式,如果使用上面命令删除时,提示有依赖的其它文件,则用该命令可以对其进行强力删除

MySQL installation steps are as follows:

Use the root user to log on to your Linux system.

Download the MySQL RPM package at: MySQL Download.

The rpm package is downloaded for you by executing the MySQ L installation with the following command:

[root@host]# rpm -i MySQL-5.0.9-0.i386.rpm

The above procedure for installing the MySQL server creates a MySQL user and creates a MySQL profile my.cnf.

You can find all MySQL-related bins in /usr/bin and/usr/sbin. All data sheets and databases will be created in the /var/lib/mysql directory.

Here are some of the installation procedures for MySQL optional packages that you can install according to your needs:

[root@host]# rpm -i MySQL-client-5.0.9-0.i386.rpm
[root@host]# rpm -i MySQL-devel-5.0.9-0.i386.rpm
[root@host]# rpm -i MySQL-shared-5.0.9-0.i386.rpm
[root@host]# rpm -i MySQL-bench-5.0.9-0.i386.rpm

MySQL is installed on Window

Installing MySQL on Window is relatively easy, you only need to download the Window version of the MySQL installation package in MySQL Downloads and unzim the installation package.

Double-click the setup .exe file, and then all you need to do is install the default configuration by clicking "next" and the installation information will be in the C: smql directory by default.

Next you can switch to the C: sm mysql\bin directory on the command prompt by entering the "cmd" command in the search box with "Start" and enter the command:

mysqld.exe --console

If the installation is successful, the above commands will output some MySQL boot and InnoDB information.


Verify mySQL installation

After a successful installation of MySQL, some of the underlying tables are initialized, and after the server is started, you can verify that MySQL is working properly with a simple test.

Use the mysqladmin tool to get server status:

Using the mysqladmin command to check the version of the server, the binary is located on /usr/bin on linux, and on window the binary is located at C: .

[root@host]# mysqladmin --version

The command on linux outputs the following results, which are based on your system information:

mysqladmin  Ver 8.23 Distrib 5.0.9-0, for redhat-linux-gnu on i386

If you do not enter any information after the above command is executed, your MySQL has not been installed successfully.


Use MySQL Client to execute simple SQL commands

You can connect to the MySQL server using the MySQL command at MySQL Client, and by default the password for the MySQL server is empty, so this instance does not need to enter a password.

The command is as follows:

[root@host]# mysql

After the above command is executed, the mysql and prompts are output, indicating that you have successfully connected to the MySQL server and that you can execute SQL commands at the mysql and prompts:

mysql> SHOW DATABASES;
+----------+
| Database |
+----------+
| mysql    |
| test     |
+----------+
2 rows in set (0.13 sec)

What you need to do after MySQL is installed

After the MySQL installation is successful, the default root user password is empty, and you can use the following command to create the root user's password:

[root@host]# mysqladmin -u root password "new_password";

Now you can connect to the MySQL server with the following commands:

[root@host]# mysql -u root -p
Enter password:*******

Note: When you enter a password, the password is not displayed, just enter it correctly.


Start MySQL when the Linux system starts

If you need to start the MySQL server when the Linux system starts, you need to add the following command in the /etc/rc.local file:

/etc/init.d/mysqld start

Similarly, you need to add mysqld binary files to the /etc/init.d/directory.