4.2.2. MySQL installation

发布时间 :2025-10-25 12:31:23 UTC      

The MySQL download address for all platforms is: MySQL 下载 . Pick what you need. MySQL Community Server Version and corresponding platform.

注意: During the installation process, we need to install it by turning on administrator privileges, otherwise it will not be able to install due to lack of permissions.

Install MySQL on Linux/UNIX

It is recommended to use the RPM package for installation on the Linux platform. Mysql,MySQL AB provides the download address for the following RPM packages:

  • 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 to connect to and operate the Mysql server.

  • MySQL-devel -Libraries and include files, which you need to install if you want to compile other MySQL clients, such as Perl modules.

  • MySQL-shared -this package contains shared libraries (libmysqlclient.so*) that some languages and applications need to load dynamically, using MySQL.

  • MySQL-bench -benchmark and performance testing tools for MySQL database servers.

Before installation, we can check whether the system comes with the installation MySQL:

rpm -qa | grep mysql

If your system is installed, you can choose to uninstall it:

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

安装 MySQL:

Next, we use the yum command to install MySQL under the Centos7 system. It is important to note that the MySQL database in CentOS 7 has been removed from the default program list, so before installation, we need to download the Yum resource package from the official website at: https://dev.mysql.com/downloads/repo/yum/ .

Image0

wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum update
yum install mysql-server

Permission settings:

chown -R mysql:mysql /var/lib/mysql/

Initialize MySQL:

mysqld --initialize

Start MySQL:

systemctl start mysqld

View the running status of MySQL:

systemctl status mysqld

注意: If this is the first time we start the mysql service, the mysql server will first do the initialization configuration.

In addition, you can also use MariaDB instead, the MariaDB database management system is a branch of MySQL, mainly maintained by the open source community and licensed by GPL. One of the reasons for developing this branch is that after Oracle acquired MySQL, there is a potential risk of shutting down MySQL, so the community uses a branching approach to avoid this risk.

The goal of MariaDB is to be fully compatible with MySQL, including API and the command line, making it an easy replacement for MySQL.

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 successfully installing MySQL, some of the underlying tables will be initialized, and after the server starts, you can verify that MySQL is working properly through a simple test.

Use the mysqladmin tool to get the server status:

Use the mysqladmin command to check the version of the server, which is located in the / usr/bin directory on linux and C:mysqlbin on Windows.

[root@host]# mysqladmin --version

This command on linux will output the following result, which is based on your system information:

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

If you do not output any information after the above command is executed, your Mysql is not installed successfully.

Use MySQL Client (Mysql client) to execute simple SQL commands

You can use the mysql command in MySQL Client (Mysql client) to connect to the MySQL server. By default, the login password of the MySQL server is empty, so there is no need to enter a password for this example.

The command is as follows:

[root@host]# mysql

The mysql > prompt will be output after the above command is executed, which indicates 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 you need to do after Mysql installation

After Mysql is installed successfully, the default root user password is empty. You can use the following command to create a 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:*******

注意: When entering the password, the password will not be displayed, you can enter it correctly.

Install MySQL on Windows

It is relatively easy to install MySQL on Windows, and the latest version can be found in MySQL 下载 View in the download ( 更详细安装: Windows 上安装 MySQL ).

Image1

Image2

Click Download Click the button to enter the download page and click the No thanks, just start my download. You can download it immediately:

Image3

After downloading, we unzip the zip package to the appropriate directory. Here, I will put the extracted folder in C:webmysql-8.0.11 Down.

接下来我们需要配置下 MySQL 的配置文件

Open the folder you just unzipped C:webmysql-8.0.11 To create under this folder my.ini Configuration files, editin my.ini Configure the following basic information:

[client]
# 设置mysql客户端默认字符集
default-character-set=utf8

[mysqld]
# 设置3306端口
port = 3306
# 设置mysql的安装目录
basedir=C:\\web\\mysql-8.0.11
# 设置 mysql数据库的数据的存放目录,MySQL 8+ 不需要以下配置,系统自己生成即可,否则有可能报错
# datadir=C:\\web\\sqldata
# 允许最大连接数
max_connections=20
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB

接下来我们来启动下 MySQL 数据库:

Open the cmd command line tool as an administrator and change directories:

cd C:\web\mysql-8.0.11\bin

Initialize the database:

mysqld --initialize --console

When the execution is complete, the initial default password of the root user is output, such as:

...
2018-04-20T02:35:05.464644Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: APWCY5ws&hjQ
...

APWCY5ws&hjQ is the initial password, which is needed for subsequent login, and you can also change the password after logging in.

Enter the following installation command:

mysqld install

Start and enter the following command:

net start mysql

Note: the data directory needs to be initialized at 5.7:

cd C:\web\mysql-8.0.11\bin
mysqld --initialize-insecure

Initialize and then run net start mysql to start mysql.

Log in to MySQL

When the MySQL service is already running, we can log in to the MySQL database through the client tool that comes with MySQL. First, open a command prompt and enter a name in the following format:

mysql -h 主机名 -u 用户名 -p

Parameter description:

  • -h Specify the MySQL hostname to which the client wants to log in. Login to the local machine (localhost or 127.0.0.1) this parameter can be omitted

  • -u User name of login

  • -p Tell the server that a password will be used to log in, and this option can be ignored if the username and password you want to log in is empty.

If we want to log in to the local MySQL database, we only need to enter the following command:

mysql -u root -p

Press enter to confirm that if the installation is correct and MySQL is running, you will get the following response:

Enter password:

If the password exists, enter the password to log in, if it does not exist, press enter to log in directly. After logging in successfully, you will see Welcome to the MySQL monitor… It’s a prompt.

Then the command prompt will always be mysql> Add a flashing cursor to wait for the input of the command, enter exit Or quit Log out and log in.

Principles, Technologies, and Methods of Geographic Information Systems  102

In recent years, Geographic Information Systems (GIS) have undergone rapid development in both theoretical and practical dimensions. GIS has been widely applied for modeling and decision-making support across various fields such as urban management, regional planning, and environmental remediation, establishing geographic information as a vital component of the information era. The introduction of the “Digital Earth” concept has further accelerated the advancement of GIS, which serves as its technical foundation. Concurrently, scholars have been dedicated to theoretical research in areas like spatial cognition, spatial data uncertainty, and the formalization of spatial relationships. This reflects the dual nature of GIS as both an applied technology and an academic discipline, with the two aspects forming a mutually reinforcing cycle of progress.