# Cd/usr/src
# Tar-zvxf mysql-3.22.25-pc-linux-gnu-i686.tar.gz (generate mysql-3.22.25-pc-linux-gnu-i686 directory)
# Cd mysql-3.22.25-pc-linux-gnu-i686
#./Configure -- prefix =/usr/local/MySQL (here, the parameter setting destination installation path)
# Make
# Make install
Note: When running configure, set the MySQL installation path to/usr/local/MySQL, which will be used during subsequent installation. Then, create the initial database:
# Scripts/mysql_install_db
This command creates two databases under/usr/local/MySQL/var/: MySQL and test. The former is the MySQL permission management database, the latter is used for exercises. Note: If you have installed MySQL before, the initial database already exists and you do not need to reinstall it.
Finally, start MYSQL:
# Cd/usr/local/MySQL/bin
#./Safe_mysqld &
If you want to automatically run the database service when the machine starts, you can add the preceding startup command to the/etc/rc. d/rc. Local file.
Now MySQL is running and waiting for your data processing command! However, be careful: You have not set a password for your root administrator. Anyone can modify your database as needed (including the most important permission database )! If you do not believe this, perform the following exercises (assuming that the current directory is/usr/local/MySQL/bin ):
Try to log on with any user and run:
$./MySQL-u Root
You can immediately go to the "mysql>" client software prompt and perform any data processing operations without any password, the MySQL administrator "root" account can use different passwords than your UNIX account. To add a password to the root account, run:
#./Mysqladmin-u Root Password 'new password'
Run the following command again as a normal user:
$./MySQL-u Root
The system prompts you to enter the password. If the password is incorrect, access is denied. In fact, even if you are a root user, if you do not explicitly specify the password, the system will reject it:
#./MySQL-u Root
Or
#./MySQL system response:
Error 1045: Access denied for user: 'root @ localhost' (using password: No)
The system will prompt you to enter the password only when the-p parameter is used and the password is correct:
#./MySQL-u root-P
Password: ******** (enter the password)
Welcome to the MySQL monitor. commands end with; or \ G.
Your MySQL connection ID is 33 to server version: 3.22.25
Type 'help' for help.
Mysql>
Type exit to return to shell.
The script mysql. Server (in the 'share/mysql' directory) is used to start or stop the MySQL server:
Shell> mysql. Server start
Shell> mysql. server stop
This script actually starts the server by executing safe_mysqld. You can also stop the server by managingProgramImplementation:
Mysqladmin Shutdown
You can also add the following command to the '/etc/rc. local' file to automatically start MySQL at system startup:
/Bin/sh-C 'CD/usr/local/MySQL;./bin/safe_mysqld &'