Mysql is installed on Linux and UNIX and Window platforms

  • 2021-01-06 00:46:54
  • OfStack

All platforms Mysql download address is: MySQL download. Choose what you need MySQL Community Server version and the corresponding platform.

1. Install Mysql on Linux/UNIX

RPM is recommended to install Mysql on the Linux platform. MySQL AB provides the following download address for RPM:

MySQL - MySQL server. You need this option, unless you only want to connect to the MySQL server running on another machine.
MySQL-client - MySQL client program for connecting to and operating Mysql server.
MySQL-devel - libraries and included files. If you want to compile other MySQL clients, such as the Perl module, you will need to install the RPM package.
MySQL-shared - This package contains shared libraries that certain languages and applications need to load dynamically (*), using MySQL.
MySQL-bench - MySQL database server benchmarking and performance testing tools.
The following example of Mysql RMP installation was performed on an SuSE Linux system, but this installation procedure can also be applied to other Linux systems that support RPM, such as Centos.

Installation steps are as follows:

Log on to your Linux system using root User.

Download the Mysql RPM package.

rpm is the rpm package you downloaded:

[root@host]# rpm -i MySQL-5.0.9-0.i386.rpm
The above process of installing the mysql server will create the mysql user and create an mysql configuration file my.cnf.

You can find all the binary files related to MySQL in /usr/bin and /usr/sbin. All data tables and databases will be created in the directory /var/lib/mysql.

The following is the installation process of some mysql optional packages, you can install according to your own 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 

2. Install Mysql on Window

Installing Mysql on Window is relatively easy. You just need to download the window version of the mysql installation package from the MySQL download and unpack the installation package.

Double click the setup.exe file, then you just need to install the default configuration and click "next". By default, the installation information will be in the C:\mysql directory.

Next you can switch to the C: mysql\bin directory at the command prompt by typing "start" = "in the search box" cmd" command = "and type 1:

mysqld.exe --console
If the installation is successful, the above command will output some mysql startup and InnoDB information.

1. Verify Mysql installation

After a successful installation of Mysql, some basic tables will be initialized. After the server starts, you can verify that Mysql is working with a simple test.

Use the mysqladmin tool to get the server status:

Use the mysqladmin command to check the version of the server. On linux the binary file is located at /usr/bin on linux, on window the binary file is located at C:\mysql\bin.

[root@host]# mysqladmin --version
This command on linux will output the following results, based on your system information:

mysqladmin Ver 8.23 Distrib 5.0.9-0, for redhat-linux-gnu on i386
If you did not enter any information after executing the above command, your Mysql was not installed successfully.

2. Execute a simple SQL command using MySQL (Mysql client)

You can use the mysql command to connect to the Mysql server from MySQL (Mysql client). By default, the Mysql server's password is empty, so you do not need to enter a password for this example.

The order is as follows:

[root@host]# mysql
The above command will output mysql when executed > Prompt, this indicates that you have successfully connected to the Mysql server, which you can use in mysql > Prompt to execute the SQL command:

| Database |
| mysql |
| test  |
2 rows in set (0.13 sec)

3, Mysql needs to be done after installation

The default password for root user is empty. You can create a password for root user by using the following command:

[root@host]# mysqladmin -u root password "new_password";
Now you can connect to the Mysql server with the following command:

[root@host]# mysql -u root -p
Enter password:*******
Note: when entering the password, the password will not be displayed. You can enter it correctly.

4. Start MySQL when the Linux system is started

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

/etc/init.d/mysqld start
Also, you need to add mysqld 2 hexadecimal file to the/etc/init d/directory.

mysql5.7: mysql 5.7: mysql5

The above is all the content of this article, I hope to help you learn.

Related articles: