Centos6.5 install MySql
There are several ways to install the MySql method, as shown below:
Serial number MySql installation characteristics show that the 1yum/rpm package installation characteristics is simple, fast, but can not be customized installation, beginners often use this way 2 binary installation decompression software, simple configuration can be used, do not need to install, faster, professional DNA like this way. Software name such as: mysql-5.5.32-linux2.6_x86_64.tar.gz3 source code compilation installation features can be customized installation, but the installation time is long, such as: character set installation path, and so on. Software name such as: mysql-5.5.32.tar.gz4 source software combined with yum/rpm installation to make the source software into a rpm that meets the requirements, put it in the yum warehouse, and then install it through yum. Combines the advantages of 1 and 3 above, that is, fast installation and business customization of parameters, but the installer also needs to have deeper capabilities.
The following is a demonstration of yum and compilation installation:
1. Yum installation
1. Close iptables
[root@mysql ~] # / etc/init.d/iptables stopiptables: Setting chains to policy ACCEPT: filter [OK] iptables: Flushing firewall rules: [OK] iptables: Unloading modules: [OK] [root@mysql ~] # / etc/init.d/iptables stop [root@mysql ~] # chkconfig iptables off
2. Close SELinux
[root@mysql ~] # sed-I's setenforce for root@mysql getenforcePermissive'/ etc/selinux/config [root@mysql ~] # setenforceusage: setenforce [Enforcing | Permissive | 1 | 0] [root@mysql ~] # getenforcePermissive
3. Install mysql
[root@mysql ~] # yum-y install mysql mysql-server mysql-develLoaded plugins: fastestmirror Securitybase | 3.7 kB 00:00 base/primary_db | 4.6 MB 00:30 extras | 3.4 kB 00:00 extras/primary_db | 37 kB 00:00 updates | 3.4 kB 00:00 updates/primary_db | 5.2 MB 00kB 43. Slightly [root@mysql ~] # chkconfig mysqld on # Boot [root@mysql ~] # chkconfig-- list | grep mysqld# queries whether to boot mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off [root@mysql ~] # boot service Starting mysqld: [OK] [root@mysql ~] # mysql # enter mysqlWelcome to the MySQL monitor. Commands end with; or\ g.Your MySQL connection id is 3Server version: 5.1.73 Source distributionCopyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.mysql > CREATE DATABASE wordpress;# create a database named Query OK, 1 row affected (0.00 sec) mysql > select user,host,password from mysql.user # query users and other information +-+ | user | host | password | +-+ | root | localhost | | root | mysql | root | 127.0.0.1 | | | localhost | mysql | | +-+ 5 rows in set (0.00 sec) mysql > set password for root@localhost=password ('root') | # query the user's password, all are empty. Use the above command to set the password of root to rootQuery OK, 0 rows affected (0.00 sec) mysql > select user,host,password from mysql.user # query again and find that there is already password information under password +-- + | user | host | password | +- +-+-+ | root | localhost | * 81F5E21E35407D884A6CD4A731AEBFB6AF209E1B | | root | mysql | root | 127.0.0.1 | | localhost | mysql | | +-- | -- + 5 rows in set (0.00 sec) mysql > exitBye [root@mysql ~] # [root@mysql ~] # mysql-u root-p # Login with the new password Enter password: # fill in the password Welcome to the MySQL monitor. Commands end with; or\ g.Your MySQL connection id is 6Server version: 5.1.73 Source distribution... Slightly mysql > exit [root@mysql ~] # [root@mysql ~] # cat / etc/my.cnf # / etc/my.cnf is the main configuration file of mysql [mysqld] datadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.sockuser=mysql# Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links= 0 [mysqld _ safe] log-error=/var/log/mysqld.logpid-file=/var/run/mysqld/mysqld.pid [root@mysql ~] # [root@mysql ~] # ls-1 / var / the database file of lib/mysql/#mysql database is stored in total 20492 Murray RW Murray RW Murray. 1 mysql mysql 10485760 May 16 22:30 ibdata1-rw-rw----. 1 mysql mysql 5242880 May 16 22:30 ib_logfile0-rw-rw----. 1 mysql mysql 5242880 May 16 22:30 ib_logfile1drwx-. 2 mysql mysql 4096 May 16 22:30 mysqlsrwxrwxrwx. 1 mysql mysql 0 May 16 22:30 mysql.sockdrwx-. 2 mysql mysql 4096 May 16 22:30 testdrwx-. 2 mysql mysql 4096 May 16 22:33 wordpress [root@mysql ~] # [root@mysql ~] # ls / var/log/# log file location anaconda.ifcfg.log anaconda.yum.log dmesg mysqld.log tallyloganaconda.log audit dmesg.old ntpstats wtmpanaconda.program.log boot.log dracut.log prelink yum.loganaconda.storage.log btmp lastlog saanaconda.syslog ConsoleKit maillog secureanaconda.xlog cron messages spooler [root@mysql ~] # [root@mysql ~] # netstat-lntup | grep 330ports view mysql port listening status tcp 0 0 0.0 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. Root@mysql * LISTEN 2053/mysqld [root@mysql ~] #
Reset the MySql password after forgetting:
# enter the password for multiple times but not [root@bogon] # mysql-u root-pEnter password: ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) [root@bogon ~] # mysql-u root-pEnter password: ERROR 1045 (28000): Access denied for user' root'@'localhost' (using password: YES) [root@bogon ~] # / application/mysql//bin/mysqladmin-u root password '789 invalid password The mysql login password is set to 789 login # [root@bogon ~] # mysql-u root-p # enter the password 789 login password # Enter mysqlEnter password: Welcome to the MySQL monitor. Commands end with; or\ g.Your MySQL connection id is 6Server version: 5.5.32 Source distributionCopyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.mysql >
Basic command
Show databases; / / View the existing database of the system
Use databasesname; / / Select the database you want to use
Drop database databasename; / / Delete selected database
Exit / / exit the connection to the database
Create database test01; / / set up a database named test
Show tables; / / lists the tables under the current database
Other basic additions, deletions, changes and queries can be done by using standard SQL.
Open remote login permissions
GRANT ALL PRIVILEGES ON *. * TO 'root'@'%' IDENTIFIED BY' root' WITH GRANT OPTION
FLUSH PRIVILEGES
Reference:
Old boy
Http://blog.csdn.net/xxd851116/article/details/22947891
Http://www.xxlinux.com/article/development/database/20121106/18532.html