MySQL for Linux
First, check whether MySQL is installed on the system. If yes, uninstall it.
Rpm-Qa | grep MySQL
Note that MySQL is case sensitive and case sensitive.
Rpm-e -- nodeps MySQL *
Be sure to use -- nodeps to uninstall without checking the dependency.
Create a user MySQL
Groupadd MySQL
Useradd-G MySQL
Passwd MySQL
Create a MySQL folder under/usr/local
After that, the installation file will be uploaded to the server. The tar.gz file is used, and the RPM package can be used. However, the RPM package cannot specify the installation directory, so it is not used.
Tar zxvf mysql-5.0.45.tar.gz
CD mysql-5.0.45
./Configure -- prefix =/usr/local/MySQL -- With-charset = gb2312
Specify the installation directory as/usr/local/MySQL and the character set as gb2312.
Make
Make install
Installation Complete
Restart
CP/usr/local/MySQL/share/MySQL. Server
/Etc/init. d/mysqld
Copy the mysqld file started
Make sure that the MySQL user has the corresponding permissions.
Chmod 700/etc/init. d/mysqld
CD/usr/local
Chmod 750 mysql-R
Chgrp MySQL mysql-R
Chown MySQL/var-R
CD/usr/local/MySQL/libexec
CP mysqld. Old
Strip mysqld
Chkconfig -- add mysqld
Chkconfig -- level 345 mysqld on
Service mysqld start
Start the service
/Usr/local/MySQL/bin/mysqld_safe
Check whether MySQL works normally.
Mysql-uroot MySQL
Or netstat-atln.
Check whether port 3306 is enabled. (If mysqld cannot be started, check the error logs under/web/MySQL/var. This is generally because the directory permission is not set)
Haha, no problem. Startup is normal.
/Usr/local/MySQL/bin/mysql_install_db -- user = MySQL
Create a database named MySQL
Next, make a link to make it easier. (Make sure that the user path contains sbin before linking)
Ln-S/usr/local/MySQL/bin/MySQL/sbin/MySQL
Ln-S/usr/local/MySQL/bin/mysqladmin/sbin/mysqladmin
Okay. Restart it if there is no problem.
Next, let's make some better settings. Let MySQL run better.
CP/usr/local/MySQL/share/MySQL/my-medium.cnf/etc/My. CNF
Copy the configuration file in three environments: large, medium, and small. Select the one based on the machine performance. If the load is heavy, you can modify the memory usage values of some variables.
Set to automatically start MySQL
Set automatic MySQL startup
# Cd/usr/local/MySQL/share/MySQL
# Cp mysql. Server/etc/init. d/MySQL
# Cd/etc/rc3.d
# Ln-S ../init. d/MySQL s100mysql
# Ln-S ../init. d/MySQL k100mysql
# Cd/etc/rc5.d
# Ln-S ../init. d/MySQL s100mysql
# Ln-S ../init. d/MySQL k100mysql
# CD ../init. d
# Chmod 755 MySQL
Restart to check whether MySQL is started automatically.
Mysqladmin-uroot password "888888"
Set the password for the root account
Mysql-uroot-P
Enter your password
Mysql> use MySQL;
Mysql> Delete from user where Password = ""; # delete an empty password account used for anonymous local connection
Mysql> Update user set host = '%' where host = 'localhost'; Set remote user logon (otherwise, only localhost can operate the database)
Mysql> flush privileges;
Mysql> quit
Everything works.