Two ways to install mysql-5.5.47 on Linux system and manage mysql
We know that there are generally two ways to install software on the Linux system. One is to use rpm or yum to install, which is convenient and fast; the other is to use the compiled source package. Although this method is more troublesome to install, it is easy to manage and can be installed according to our own wishes. So we will introduce the second installation method here. In addition, there is another way that is similar to the green software under Windows, that is, it is a universal binary software that can be used without installation and decompression. Let's introduce them separately. The system used here is Centos, and MySQL is MySQL5.5.47 version.
Install MySQL universal binary software under CentOS
You can click here to download the software used for MySQL installation . After the download is complete, we will start our installation journey.
mysql_install_db
--user
=
mysql
//Install the database
10. # chown –R root . //Change the user of all files to root (note the dot at the end, indicating the current directory)
11. # chown –R mysql data //Change the user of the data directory to mysql
12. # cp support-files/my-medium.cnf /etc/my.cnf //mysql configuration file
Note: This method requires the Linux system root user, that is, administrator privileges, and this installation method defaults to a blank password for the MySQL user root, that is, no password.
So far, MySQL has been successfully installed using the universal binary method.
Install MySQL using source package under CentOS
The MySQL installation source package can be downloaded here . The following is the installation process
1. # groupadd mysql //Create a new user group2
. # useradd –r –g mysql –s /bin/false mysql //Create a new mysql user. Note that -s /bin/false means that the user is not given permission to log in to the system3
. # tar –zxvf mysql-5.5.47.tar.gz
4. # cd mysql-5.5.47
5. # cmake . //Use cmake to precompile (note that there is a dot at the end, indicating the current directory)
6. # make && make install //Compile and install7
. # chown –R mysql . //Change the user of all files in the mysql directory to mysql (note that there is a dot at the end, indicating the current directory)
8. # chgrp –R mysql . //Change the group of all files in the mysql directory to mysql (note that there is a dot at the end, indicating the current directory)
9. # scripts/mysql_install_db --user=mysql //Install the database10
. # chown –R root . //Change the user of all files to root (note that there is a dot at the end, indicating the current directory)
11. # chown –R mysql data //Change the owner of the data directory to mysql
12. # cp support-files/my-medium.cnf /etc/my.cnf //mysql configuration file
According to the above steps, the installation can be successful under ideal circumstances.
There are three points to note in step 5
1. The system needs to have cmake software. If cmake is not installed, it will prompt in step 5
bash: cmake: command not found
The solution is to install the cmake software
# yum install cmake
2. Before running cmake, we need to ensure that the curses library exists in the system. If the curses library does not exist, the following error will be reported when running cmake
Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH)
CMake Error at cmake/readline.cmake:83 (MESSAGE):
Curses library not found.Please install appropriate package,
remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.
Call Stack (most recent call first):
cmake/readline.cmake:127 (FIND_CURSES)
cmake/readline.cmake:217 (MYSQL_USE_BUNDLED_LIBEDIT)
CMakeLists.txt:354 (MYSQL_CHECK_READLINE)
-- Configuring incomplete, errors occurred!
解决办法就是安装ncurses库,对于ncurses库我们可以点此下载。安装方法如下
1. # tar –zxvf ncurses-6.0.tar.gz
2. # cd ncurses-6.0
3. # ./configure
4. # make && make install
安装成功以后需要重新使用cmake 进行配置,但是由于在第一次使用cmake时会产生一个CMakeCache.txt缓存文件,我们需要将此文件删除,否则会报和第一次相同的错误。
删除以后再次使用cmake . 命令就可以成功进行配置了
3. 安装完成以后其默认安装目录为/usr/local/mysql 可使用选项 –DCMAKE_INSTALL_PREFIX = 安装目录 修改安装目录
Mysql简单管理
接下来主要介绍一下如何管理mysql,上述两种安装方式虽然安装不同,但是其管理方式是一样的。
# /usr/local/mysql/bin/mysqld_safe –user=mysql & //启动mysql服务
# netstat –an | grep 3306 //查看mysql服务监听的端口
# ps –ef | grep mysql //查看mysql进程是否存在
# /usr/local/mysql/bin/mysqladmin shutdown –p //关闭mysql服务
然后我们将mysql服务加入系统服务进行管理
# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
# service mysqld start //开启mysql服务
# service mysqld stop //关闭mysql服务
配置mysql服务自启动
# chkconfig –add mysqld
# chkconfig –list | grep mysqld //查看mysqld服务的状态
mysqld 0:关闭 1:关闭 2: 关闭 3: 关闭 4: 关闭 5: 关闭 6:关闭
# chkconfig –level 3 mysqld on
# chkconfig –level 5 mysqld on
# chkconfig –list | grep mysqld
mysqld 0:关闭 1:关闭 2: 关闭 3: 启用 4: 关闭 5: 启用 6:关闭
这样mysql服务就会随着系统启动而自动开启了
For reprinting, please send an email to 1244347461@qq.com for approval. After obtaining the author's consent, kindly include the source as a link.
Related Articles
How to back up a Kubernetes MySQL Operator cluster
Publish Date:2025/04/26 Views:79 Category:MySQL
-
Oracle's MySQL Operator for Kubernetes is a convenient way to automatically configure a MySQL database within a cluster. One of the key features of the Operator is the integrated automatic backup support for increased resiliency. The backup
How to select from multiple tables in MySQL
Publish Date:2025/04/25 Views:58 Category:MySQL
-
This article explains how to use MySQL to query from multiple tables in one script SELECT . Let's demonstrate a situation: SELECT name , price, details, type , FROM food, food_order WHERE breakfast.id = 'breakfast_id' Now, let's imagine FRO
Creating a table from CSV in MySQL
Publish Date:2025/04/25 Views:115 Category:MySQL
-
In this article, we aim to understand how to create a table from CSV in MySQL database. Businesses and organizations must quickly generate tables from large amounts of data. These organizations typically have large CSV files with large amou
Creating a Temporary Table in MySQL
Publish Date:2025/04/25 Views:183 Category:MySQL
-
In this article, we aim to explore different ways to create temporary tables in MySQL. One of the main features of temporary tables is that it helps in storing temporary data. This feature is enabled in MySQL 3.23 and later versions. These
Truncate all tables in Mysql
Publish Date:2025/04/25 Views:90 Category:MySQL
-
Today I will show you how to truncate all tables in Mysql. It is used when you want to delete the entire table TRUNCATE TABLE . TRUNCATE It is a type of DML statement, which means it cannot be rolled back once it is committed. There are two
Different ways to check if a row exists in a MySQL table
Publish Date:2025/04/25 Views:164 Category:MySQL
-
This article highlights different ways to check if a row exists in a MySQL table. We will use the EXISTS and NOT EXISTS operators. We can also use these two operators with IF() the function to get a meaningful message if a row (a record) is
Check if table exists in MySQL
Publish Date:2025/04/25 Views:195 Category:MySQL
-
This article provides several options to check if a table exists in MySQL. Before discussing it, let us first see what a table is in MySQL and when you need to check its existence. What is a table in MySQL? A table is a database object that
Rename columns in MySQL database
Publish Date:2025/04/25 Views:81 Category:MySQL
-
In this article, we aim to explore different ways to rename columns in MySQL. ALTER TABLE The command is mainly used to change the format of a given MySQL table. It can be used to add columns, change the data type within a column, delete co
Copying a table in MySQL
Publish Date:2025/04/25 Views:143 Category:MySQL
-
The purpose of this article is to explore different ways to create a copy of a table in MySQL. The source table is also called the table to be copied, and the target table is called the clone table, which can be from the same or a different