linux install mysql5

Download address: http://xiazai.zol.com.cn/detail/27/264218.shtml

 

1. Install and configure MySQL

The mysql here is a binary package, and the binary package can be installed without compiling

(1) Execute in the mysql binary package directory:
# tar zxvf mysql-5.0.41-linux-i686.tar.gz
//Copy the directory generated after decompression to /usr/local/ and rename it to mysql
# mv mysql-5.041 /usr/local/mysql

(2) Create a mysql group and user, and add the mysql user to the mysql group
# groupadd mysql
# useradd -g mysql mysql

(3) There are 4 template files in the support-files directory. We select one of the Mysql configuration files and overwrite /etc/my.cnf (the system default configuration, which sets performance parameters and some path parameters of Mysql)
# cp /usr/local/mysql/support-files/my-medium.cnf /etc/my.cnf

(4) Enter the mysql directory, initialize the table and specify the mysql user to access. After initializing the table, set access permissions for mysql and root users
cd /usr/local/mysql
./scripts/mysql_install_db --user=mysql

(5) Set root to access /usr/local/mysql
# chown -R root .

(6) Set the mysql user to access /usr/local/mysql/data, which stores the mysql database file. This directory is configured in /etc/my.cnf, which is generated during mysql_install_db.
# chown -R mysql data

(7) Set the mysql user to access all files under /usr/local/mysql/data/mysql
# chown -R mysql data/.

(8) Set the mysql group to be able to access /usr/local/mysql
# chgrp -R mysql .

(9) 运行mysql
# /usr/local/mysql/bin/mysqld_safe --user=mysql &

If there is no problem, a prompt similar to this should appear:
[1] 42264
# Starting mysqld daemon with databases from /usr/local/mysql/var
If a statement like mysql ended appears, it means that Mysql did not start normally, you can go to the log Find the problem in, the Log file is usually configured in /etc/my.cnf. Most problems are caused by incorrect permission settings.
You can check whether port 3306 is occupied. If it is occupied, turn it off
lsof -i:3306
/usr/local/mysql/bin/mysqladmin shutdown -u root -p

(10) Use the following command to modify the MYSQL password
//The default installation password is empty, you must modify it immediately for security.
# /usr/local/mysql/bin/mysqladmin -u root password yourpassword

(11) Set mysql to run automatically every time it starts
# cp support-files/mysql.server /etc/rc.d/init.d/mysqld
# chmod 700 /etc/init.d/mysqld
# chkconfig --add mysqld
# chkconfig --level 345 mysqld on

(12) Start the mysqld service and check whether port 3306 is open. Be careful to open this port in the firewall.
# service mysqld start
# netstat -atln

Modify the database to log in remotely:
update mysql.user set host='%' where user='root' and host='localhost';

After changing the password, turn off the firewall
service iptables stop

Restart mysql: command
cd /usr/local/mysql/bin
./mysqladmin shutdown –u root –p
enter password 111111
./safe_mysqld –user=root &

启动MySQL
/usr/local/mysql/bin/safe_mysqld --user=root &

Stop MySQL
mysqladmin shutdown -u root -p

Enter the mysql command line:
mysql -u root -p
Enter the password:

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327042604&siteId=291194637