Install MySQL How to install MySQL under UNIX system

WBOY
Release: 2016-07-29 08:33:55
Original
933 people have browsed it

# cd /usr/src
# tar -zvxf mysql-3.22.25-pc-linux-gnu-i686.tar.gz (generates the mysql-3.22.25-pc-linux-gnu-i686 directory)
# cd mysql- 3.22.25-pc-linux-gnu-i686
# ./configure --prefix=/usr/local/mysql (where the parameter sets the destination installation path)
# make
# make install
Note that when running configure, set Set the installation destination path of MySQL as /usr/local/mysql, which will be used in subsequent installation processes. Then, create the initial database:
# scripts/mysql_install_db
This command will create two databases under /usr/local/mysql/var/: mysql and test, the former is MySQL’s permission management database, and the latter allows you to For practice. Note: If you have installed MySQL before, the initial database already exists and there is no 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 above startup command to /etc/rc. d/rc.local file.
Now, MySQL is running and waiting for your data processing commands! However, be careful: you have not set a password for your root administrator, anyone can modify your database (including the most important permissions database) as they like! If you don’t believe it, do the following exercise (assuming that our current directory is /usr/local/mysql/bin):
Try to log in with any user and run:
$ ./mysql -u root
You can enter "mysql>" immediately ;" client software prompt and perform any data processing operations without requiring any password; this means that the password used by the MySQL administrator "root" account and your Unix account can be different. In order to add a password to the root account, execute:
# ./mysqladmin -u root password 'new password'
Execute again as a normal user:
$ ./mysql -u root
The system will prompt you to enter the password. If the password is incorrect, access denied. In fact, even if you are a root user, if you do not explicitly specify the password, the system will still refuse:
# ./mysql -u root
or
# ./mysql System response:
ERROR 1045: Access denied for user: ' root@localhost' (Using password: NO)
Only if you use the -p parameter and clearly indicate that you want to use a password, the system will prompt you to enter the password, and you can enter only when the password is correct:
# ./mysql -u root -p
password:******** (Enter 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 the shell.
The script mysql.server (located 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. Stopping the server can also be achieved through the management program:
mysqladmin shutdown
You can also add the following command to the `/etc/rc.local' file to automatically start MySQL when the system starts:
/bin/sh -c 'cd /usr /local/mysql ; ./bin/safe_mysqld &'

The above introduces how to install MySQL under UNIX system, including the installation of MySQL. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template