How to install MySQL database?Install mysql step by step tutorial

how to installMySQL database?Installmysqlstep by step tutorial

MySQL installation

The Mysql download address for all platforms is: MySQL download. Pick what you need MySQL Community Server version and corresponding platform.


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 are Centos Use the yum command to install MySql under the 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 start

note:If we start the mysql service for the first time, 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 mariadb 

The 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:When entering the password, the password will not be displayed, you can enter it correctly.


Install Mysql on Windows

Installing Mysql on Windows is relatively simple, you only need to MySQL downloadDownload the Windows version of the mysql installation package and decompress the installation 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.

Hope Chen Weiliang Blog ( https://www.chenweiliang.com/ ) shared "How to install MySQL database?Install mysql step by step tutorial" to help you.

Welcome to share the link of this article:https://www.chenweiliang.com/cwl-451.html

Welcome to the Telegram channel of Chen Weiliang's blog to get the latest updates!

🔔 Be the first to get the valuable "ChatGPT Content Marketing AI Tool Usage Guide" in the channel top directory! 🌟
📚 This guide contains huge value, 🌟This is a rare opportunity, don’t miss it! ⏰⌛💨
Share and like if you like!
Your sharing and likes are our continuous motivation!

 

Comment

Your email address will not be published. Required fields * Callout

scroll to top