4. Install MySQL
[[email protected] ~]# wget http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.45-linux2.6-x86_64.tar.gz # download MySQL 5.5 version, the download process is long, need to wait for a moment
[[Email protected] ~]# tar XF mysql-5.5.45-linux2.6-x86_64.tar.gz-c/usr/local/# extract MySQL to/usr/local/directory
[[email protected] local]# cd/usr/local/# Enter this directory
[[Email protected] local]# mv mysql-5.5.45-linux2.6-x86_64 MySQL #重新命名mysql This step is necessary.
[Email protected] local]# groupadd-r-G 306 MySQL #创建mysql用户组
[Email protected] local]# useradd-r-u 306-g 306-d/dev/null-s/sbin/nologin MySQL #创建mysql用户
[Email protected] local]# tail-n 1/etc/passwd #查看是否创建了mysql用户
Mysql:x:306:306::/dev/null:/sbin/nologin
[[email protected] local]# chown-r mysql:mysql/usr/local/mysql/# to MySQL directory all files MySQL owner and have group permissions
[[email protected] local]# chmod-r 755/usr/local/mysql/# to MySQL directory all files 755 permissions
################################ [[email protected] local]# Mkdir/data # CREATE database File store directory ###########
################################[[email protected] local]# chown-r mysql:mysql/data/# give permission #################
[Email protected] mysql]# cd/usr/local/mysql/support-files/
[Email protected] support-files]# Rpm-qa | grep MySQL # View the system MySQL before you have installed
Mysql-libs-5.1.71-1.el6.x86_64
[[email protected] support-files]# rpm-e--nodeps mysql-libs # Force Uninstall the package
[[email protected] support-files]# cp-a mysql.server/etc/init.d/mysqld # Add MySQL service to default directory
[[email protected] support-files]# cp-a my-large.cnf/etc/my.cnf # Add master profile for MySQL
###################[[email protected] support-files]# vim/etc/my.cnf # edit MySQL master config file ###########################
###################### #39 thread_concurrency = 2 39 rows, this parameter is set the number of CPUs, is generally the actual number of CPUs *2###################
######################## #40 Datadir=/data40 Line, this behavior manually add the database file storage directory #########################
######################## #然后保存退出 ####################################
[Email protected] support-files]# CD. # back to the top level
[[email protected] mysql]#./scripts/mysql_install_db--user=mysql # MySQL Initialization
Note: It's okay to have an alarm in the initialization, please check if there is an error.
[[Email protected] mysql]# service mysqld start
Starting MySQL. [OK]
Above for the correct start of MySQL
Then use ln-s/usr/local/mysql/bin/mysql/usr/bin the command side can use MySQL to enter the process
[Email protected] apache-tomcat-7.0.64]# chkconfig--add mysqld
[Email protected] apache-tomcat-7.0.64]# chkconfig--list mysqld
Mysqld 0:off1:off2:on3:on4:on5:on6:off
Add MySQL as the boot service
[Email protected] ~]# vim/etc/rc.local
#!/bin/sh
#
# This script is executed *after* all and the other init scripts.
# can put your own initialization stuff in here if you don ' t
# want to does the full Sys V style init stuff.
Touch/var/lock/subsys/local
/bin/sh/usr/local/apache-tomcat-7.0.64/bin/startup.sh # Add Tomcat for boot boot
[[email protected] mysql]# vim/etc/profile.d/mysql.sh # Add the Mysql/bin directory to the PATH environment variable so it's easy to execute MySQL commands
Export path= $PATH:/usr/local/mysql/bin
Save exit
[[email protected] mysql]# source/etc/profile.d/mysql.sh # execution takes effect immediately
[[email protected] ~]# Vim/etc/sysconfig/iptables # Modify firewall rules
-A input-m state--state new-m tcp-p TCP--dport 8080-j ACCEPT
-A input-m state--state new-m tcp-p TCP--dport 8009-j ACCEPT
Save exit
[[Email protected] ~]# service iptables restart# Restart takes effect
Select Host,user from user;
Modify MySQL Password
By logging into the MySQL system,
# mysql-uroot-p
Enter Password: "Enter the original password"
Mysql>use MySQL;
mysql> Update user Set Password=password ("test") where user= ' root ';
mysql> flush Privileges;
Mysql> exit;
Set the password under MySQL console
[HTML] View plain copy on code to see a snippet derived from my Code slice
Grant all privileges on * * to ' root ' @ '% ' identified by ' 123456 ' with GRANT option; Console password
[HTML] View plain copy on code to see a snippet derived from my Code slice
Root is the user name,% indicates any host, ' 123456 ' specified login password (this and local root password can be set differently, does not affect each other)
[HTML] View plain copy on code to see a snippet derived from my Code slice
Flush privileges; Overloaded system permissions
[HTML] View plain copy on code to see a snippet derived from my Code slice
exit;//exit MySQL Console
Cenos installing MySQL