Article directory
How to install a MySQL database ? MySQL installation tutorial.
MySQL installation
The download address for MySQL on all platforms is: MySQL Download . Select the MySQL Community Server version and corresponding platform that you need .
LinuxInstall Mysql on /UNIX
It is recommended to use the RPM package to install Mysql on the Linux platform. MySQL AB provides the download address of the following RPM package:
- MySQL – MySQL server.You need this option unless you only want to connect to a MySQL server running on another machine.
- MySQL-client – MySQL client program, used to connect and operate Mysql server.
- MySQL-devel – Libraries and include files, if you want to compile other MySQL clients, such as Perl modules, you need to install this RPM package.
- MySQL-shared - ShouldsoftwareThe package contains shared libraries (libmysqlclient.so*) that certain languages and applications need to dynamically load, using MySQL.
- MySQL-bench – A benchmark and performance testing tool for the MySQL database server.
Next, we will use the yum command to install MySQL on the CentOS system:
Check whether the system comes with mysql installed:
rpm -qa | grep mysql
If your system has it installed, you can choose to uninstall it:
rpm -e mysql // 普通删除模式 rpm -e --nodeps mysql // 强力删除模式,如果使用上面命令删除时,提示有依赖的其它文件,则用该命令可以对其进行强力删除
Install mysql:
yum install mysql yum install mysql-server yum install mysql-devel
Start mysql:
service mysqld startNote: If this is the first time we are starting the MySQL service, the MySQL server will first perform initial configuration.
In case of CentOS 7 version, since the MySQL database has been removed from the default program list, mariadb can be used instead:
yum install mariadb-server mariadbThe relevant commands for the mariadb database are:
systemctl start mariadb #启动MariaDB systemctl stop mariadb #停止MariaDB systemctl restart mariadb #重启MariaDB systemctl enable mariadb #设置开机启动
Verify Mysql installation
After a successful installation of Mysql, some basic tables will be initialized. After the server is started, you can verify that Mysql is working properly by a simple test.
Use the mysqladmin tool to get server status:
Use the mysqladmin command to check the version of the server, the binary is located at /usr/bin on linux on linux and C:\mysql\bin on windows.
[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 no information is entered after the above command is executed, it means that your Mysql is not installed successfully.
Use MySQL Client (Mysql client) to execute simple SQL commands
You can use the mysql command to connect to the Mysql server in the MySQL Client (Mysql client). By default, the password of 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> prompt will be output, which means that you have successfully connected to the Mysql server. You can execute the SQL command at the mysql> prompt:
mysql> SHOW DATABASES; +----------+ | Database | +----------+ | mysql | | test | +----------+ 2 rows in set (0.13 sec)
What needs to be done after Mysql is installed
After Mysql is installed successfully, the default root user password is empty, you can use the following command to create the root user password:
[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: The password will not be displayed while you are entering it; just enter it correctly.
Install Mysql on Windows
Installing MySQL on Windows is relatively simple. You just need to download the Windows version of the MySQL installer from the MySQL download page and extract the package.
Double-click the setup.exe file, and then you only 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 on the command prompt through "Start" = "input "cmd" command in the search box, and enter the command:
mysqld.exe --console
If the installation is successful, the above command will output some mysql startup and InnoDB information.
Hopefully, the article "How to Install a MySQL Database? A Step-by-Step Tutorial" shared on Chen Weiliang's blog ( https://www.chenweiliang.com/ ) will be helpful to you.
Feel free to share this article's link: https://www.chenweiliang.com/cwl-451.html
