In Linux systems, Mysql is an important and widely used database management system. This article will introduce how to install Mysql under Linux.
1. What you need to know before installation
Before installing Mysql, you need to know the following:
2. Download the Mysql installation package
Download the Mysql installation package for Linux from the official website and extract it locally.
3. Install dependency packages
Before installing Mysql in a Linux system, you need to install the following software dependency packages:
sudo yum install cmake sudo yum install ncurses-devel sudo yum install bison sudo yum install gcc-c++ sudo yum install zlib-devel sudo yum install perl
4. Install Mysql
sudo cmake .
This statement is to generate a Makefile so that we can compile through the make command.
sudo make
This operation will take a long time, please do not terminate it before it is completed.
sudo make install
This operation will also take some time, please wait patiently.
4. Configure Mysql
The default user name of Mysql is root, and the password is empty; for security reasons, you need to set a new password for it.
After the installation is completed, if you need to start the Mysql service, you need to run the mysql service. Execute the following command in the Mysql directory:
cd /usr/local/mysql/bin/ ./mysqld_safe &
This command will start the mysql process service.
Execute the following command to enter the Mysql service:
mysql -uroot
Here -u specifies the user name, and root is the Mysql default user name.
Set a new password and apply:
mysql>UPDATE mysql.user SET password=PASSWORD('yourpassword') WHERE User='root'; mysql>FLUSH PRIVILEGES;
Among them, replace yourpassword with the password you need.
Find the my.cnf file in the /etc directory and modify it through editing tools such as vi. Below is a sample configuration that you can copy into your my.cnf file.
[client] port = 3306 socket = /tmp/mysql.sock default-character-set = utf8 [mysqld] port = 3306 socket = /tmp/mysql.sock basedir = /usr/local/mysql datadir = /var/mysql pid-file = /tmp/mysqld.pid user = mysql bind-address = 192.168.1.100 server-id=1 init-connect='SET NAMES utf8' character-set-server = utf8 skip-character-set-client-handshake max_connections=1000 log-bin = mysql-bin binlog-format=ROW expire_logs_days = 5 default-storage-engine = InnoDB innodb_file_per_table = 1
After completing the above configuration, restart the Mysql service:
service mysqld restart
At this point, the installation and configuration of Mysql are completed. Now you can log in using your newly set password and use Mysql.
The above is the detailed content of Install mysql under linux. For more information, please follow other related articles on the PHP Chinese website!