Mysql Database Installation
1. First download the installation package and run the tar command to decompress the package:
Tar-zxvf mysql-5.1.30.tar.gz
Run the cd command to enter the decompressed directory.
./Make clean before configure
Note: When "make clean" is executed, the system prompts the error checking for termcap functions library... configure: error: Nocurses/termcap library found.
Execute the./configure command and run the following code:
./Configure -- prefix =/usr/share/mysql/-with-charset = utf8-with-extra-charsets = all-With-named-curses-libs =/usr/lib/libncursesw. so.5 (The last command can be omitted)
Error:No curses/termcap library foundOrSeethe install manual chapter in the reference
Yum-y installgcc yum install ncurses-devel
2. Configure and compile the installation environment
2.1 configure the installation environment
Command Format:./configure-prefix = installation path
-- Prefix =/usr/local/mysql/install to this directory
My operations:./configure -- prefix =/usr/local/mysql/
-With-charset = gbk-with-extra-charsets = all
./Configure -- prefix =/usr/share/mysql/-with-charset = gbk-with-extra-charsets = all
Parameter: -- prefix = indicates the software installation path.
2.2 compile and install the environment
Command Format: make
An error occurred while executing the make command: exec g ++ not found
Install gcc-c ++
Re-execute the previous command (config)
Wait .......... Too long
2.3 Installation
Command Format: makeinstall
3. Create MySQL users
Use the groupadd command to create a user group
Command Format: groupaddmysql
Use the command useradd to create a user and assign it to the mysql group.
Command Format: useradd-g mysql
Run passwd to change the user password.
Command Format: passwdmysql
My password: password
4. Configure the MySQL database environment
4. 1. Use the command cp to copy the sample configuration file to the system environment
Command Format: In the extracted directory
Cp./support-files/my-medium.cnf/etc/my. cnf
To copy the target file my. cnf must be named like this, which is the default configuration file of the database.
4. Use the command VI to edit the configuration file
Command Format: vi/etc/my. cnf
Search/skip/followed by search content
Check whether the skip-federated option is enabled and comment it out.
Save and exit
5. initialize the system database
. Use the command cd to enterThe installation directory is the above/user/local/mysql
Command Format: cd/$ MYSQL_HOME
If you use the parameter-prefixEnter the path specified by the parameter; otherwise, enter/usr/local.Default path search
. Use the chown command to modify the installation directory permission
Command Format: chown-Rmysql: root... indicates the content in the current directory and below it
5. 3. initialize the system database
Command Format: bin/mysql_install_db -- user = mysql
Show some help information
6. modify Database Security
6.1 modify Database folder Permissions
Command Format: chown-R mysql var
VarThe default data folder of the database. The folder name depends on the actual situation.
6.2 start the service and modify the root user password command format:
Bin/mysqld_safe-user = mysql &
Bin/mysqladmin-u root password''
The following are some modification commands.
Bin/mysqladmin-u root-h $ hostname password''
Please remember to set a password for THEMySQL root USER!
To do so, start the server, then issue thefollowing commands:
Modify the root Login Password
/Usr/local/mysql/bin/mysqladmin-u rootpassword 'new-password'
Change test password
/Usr/local/mysql/bin/mysqladmin-u root-htest password 'new-password'
You can start the MySQL daemon:
Cd/usr/local/mysql;/usr/local/mysql/bin/mysqld_safe &
7. Test the database
Command Format: bin/mysql-u root-p
The password is empty.
Mysql statement: show databases;
Exit ctrl + c bye or exit depends on the environment
The following has never been used
Connect the external client to MySQL and log on to the MySQL server first:
Format: grant permission on database object to user
Mysql> grant all on *. * to 'root' @ '%' identified by 'root password'
1. Copy the database STARTUP script to the installation directory.
Command Format:
Cp/MySQL-version-OS/support-files/mysql. server/$ MySQL_HOME/bin/mysql. server
My operations:
Cp/root/downloads/mysql-5.1.30/support-files/mysql. server/usr/local/mysql/bin/mysql. server
2. Modify the execution permission
Command Format: chmod 755/$ MySQL_HOME/bin/mysql. server
Command explanation: chmod is a command for setting file permissions in Linux. The following numbers indicate permissions of different users or user groups.
Generally, there are three numbers:
The first number indicates the permission of the file owner.
The second number indicates the permissions of other users in the same user group as the file owner.
The third digit indicates the permissions of other user groups.
There are three types of permissions: Read (r = 4), write (w = 2), and execute (x = 1 ). In combination, there are also readable executable (rx = 5 = 4 + 1) and readable writable (rw = 6 = 4 + 2), readable and writable (rwx = 7 = 4 + 2 + 1 ).
Therefore, chmod 755 sets the user's permissions:
1. The file owner can read, write, and execute
2. Other users in the same user group as the file owner can read and execute
3. Other user groups can be read and executed
The difference between chmod 4755 and chmod 755 is that there is one more character at the beginning. This 4 indicates that other users have the same permissions as the owner when executing files.
For example, the root user has created an Internet authentication program netlogin. If other users want to use this program to access the Internet, the root user needs to run the chmod 755 netlogin command so that other users can run netlogin.
However, when executing netlogin, you may need to access some files that only the root user can access. Other users may not be able to access the Internet when executing netlogin due to insufficient permissions.
In this case, you can use chmod 4755 netlogin to set the permissions of other users to execute netlogin, so that they can access the Internet smoothly.
3. Usage
Mysql. server start | stop | restart
/Etc/profile echo $ PATH
4. Modify the environment variable so that mysql. server can be executed anywhere.
Vi/etc/profile
MYSQL_HOME =/usr/local/mysql
PATH = $ PATH: $ MYSQL_HOME/bin
Export MYSQL_HOME PATH. Note that export must be in lower case.
Source/etc/profile restart with environment variables can be found anywhere
Command explanation: after the Source command is executed, the configuration can be loaded without restarting the computer. Restart the computer with the command reboot
For example, mysql. serverstart starts mysql at any location.
I went back to the root directory and tested it.
Environment variable configuration: can be entered under any directory
Netstat-anp | more port: 3306 mysql port number
View port number command: showvariables like 'Port'
The installation is complete.
You can use mysql-u root-p to log on to mysql at any location.
Database character modification:
Mysql> Alter database test character set 'utf-8'
Library File Import:
Mysql> source SQL file path
System Character Set modification: Content in the/etc/sysconfig/i18n File
LANG = "zh_CN.GB18030"
LANGUAGE = "zh_CN.GB18030: zh_CN.GB2312: zh_CN"
SUPPORTED = "zh_CN.UTF-8: zh_CN: zh: en_US.UTF-8: en_US: en"
SYSFONT = "lat0-sun16
Solution to remote connection to mysql error 1130 code
I am using a remote connection to the Mysql server database today. No matter how it is connected, the ERROR code is 1130, ERROR 1130: Host 192.168.2.159 is not allowedto connect to this MySQL server
It is assumed that the remote connection User Permissions cannot be granted. As a result, the mysql database can be operated. After logging on to mysql on the local machine, change the "host" item in the "user" table in the "mysql" database, and rename it '%' from "localhost '..
Mysql-u root-p
Mysql> use mysql;
Mysql> select 'host' from user where user = 'root ';
Mysql> update user set host = '%' where user = 'root ';
Mysql> flush privileges;
Mysql> select 'host' from user where user = 'root ';
The first sentence is to authorize the User root to log on.
Second sentence: Select mysql database
Third sentence: view the host value of the user table in the mysql database (the host/IP name that can be accessed through connection)
Fourth sentence: Modify the host value (add host/IP address with the wildcard % content), of course, you can also directly add IP addresses
Fifth sentence: refresh the MySQL system permission table
The sixth statement is modified when you re-view the user table ..
Restart the mysql service.
======================================
1. This error occurs when you connect to MySQL through mysql-Front or mysqladministrator.
ERROR 1130: Host ***. *** is not allowed to connect to this MySQL server
This indicates that the connected user account does not have the permission for remote connection and can only log on to the Local Machine (localhost.
You need to change the host entry in the user table of the mysql database.
Rename localhost as %
First, log on to the Mysql server by following the steps below
To log on to mysql, you need to switch to the bin directory of mysql under dos and perform the following operations:
Syntax format: mysql-h host_name-u user_name-ppassword (Local-h and host_name can be saved)
For example:
C: \ program files \ mysql server 5.0 \ bin> mysql-u root-p
Enter password :******
First enter the username and password login requirements (-p), press enter, and then "Enterpassword:" appears, then enter the password and press Enter. Then you can
Log on to mysql. Otherwise, the logon fails.
After successful login, the following information and Mysql identifier are displayed:
Welcome to the MySQL monitor. Commands end with; or \ g.
Your MySQL connection id is 1 to server version: 5.0.1-nt
Type 'help; 'or' \ H' for help. Type '\ C' to clear the buffer.
Mysql>
Identifier "mysql>", when you see ......