系统环境:
MySQL数据库:hostname:Master-Mysql-Server #IP:192.168.199.176/24 Centos 6.4 2.6.32-358.el6.x86_64
预安装:
0 |
[root@Master-Mysql-Server ~]# yum install vim gcc gcc-c++ wget tree lsof ncurses-devel -y |
预配置:
0 1 2 3 4 |
[root@Master-Mysql-Server ~]# mkdir /byrd/server -p [root@Master-Mysql-Server ~]# mkdir /byrd/tools [root@Master-Mysql-Server ~]# cd /byrd/tools [root@Mysql5-Server tools]# wget http://down1.chinaunix.net/distfiles/mysql-5.1.51.tar.gz [root@Mysql5-Server tools]# tar zxvf mysql-5.1.51.tar.gz |
配置:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
[root@Mysql5-Server tools]# cd mysql-5.1.51 [root@Mysql5-Server mysql-5.1.51]# useradd mysql -s /sbin/nologin –M [root@Mysql5-Server mysql-5.1.51]# ./configure --prefix=/byrd/server/mysql5.1.51 --with-unix-socket-path=/byrd/server/mysql5.1.51/tmp/mysql.sock --localstatedir=/byrd/server/mysql5.1.51/data --enable-assembler --enable-thread-safe-client --with-mysqld-user=mysql --with-big-tables --without-debug --with-pthread --enable-assembler --with-extra-charsets=complex --with-readline --with-ssl --with-embedded-server --enable-local-infile --with-plugins=partition,innobase --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static [root@Mysql5-Server mysql-5.1.51]# make && make install [root@Mysql5-Server mysql-5.1.51]# cd /byrd/server/mysql5.1.51/ [root@Mysql5-Server mysql5.1.51]# ln -s /byrd/server/mysql5.1.51/ /usr/local/mysql [root@Mysql5-Server mysql5.1.51]# mkdir -p /usr/local/mysql/data [root@Mysql5-Server mysql5.1.51]# chown -R mysql /usr/local/mysql [root@Mysql5-Server mysql5.1.51]# /usr/local/mysql/bin/mysql_install_db --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/ --user=mysql [root@Mysql5-Server mysql5.1.51]# cp /byrd/tools/mysql-5.1.51/support-files/mysql.server /usr/local/mysql/bin/ [root@Mysql5-Server mysql5.1.51]# cp /byrd/tools/mysql-5.1.51/support-files/my-small.cnf /etc/my.cnf [root@Mysql5-Server bin]# chmod 755 /usr/local/mysql/bin/mysql.server [root@Mysql5-Server bin]# cp /usr/local/mysql/bin/mysql.server /etc/init.d/mysqld [root@Mysql5-Server bin]# service mysqld start [root@Mysql5-Server bin]# netstat -tunlp|grep 3306 [root@Mysql5-Server bin]# lsof -i :3306 |
测试:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
[root@Mysql5-Server bin]# mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.1.51 Source distribution Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. This software comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to modify and redistribute it under the GPL v2 license Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | test | +--------------------+ 3 rows in set (0.00 sec) mysql> mysql> select user(); +----------------+ | user() | +----------------+ | root@localhost | +----------------+ 1 row in set (0.00 sec) mysql> [root@Mysql5-Server bin]# mysqladmin -u root password 'admin123' [root@Mysql5-Server bin]# mysql ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) [root@Mysql5-Server bin]# [root@Mysql5-Server bin]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 6 Server version: 5.1.51 Source distribution Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. This software comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to modify and redistribute it under the GPL v2 license Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> [root@Mysql5-Server bin]# mysql -uroot -p'admin123' mysql> drop user''@'localhost'; Query OK, 0 rows affected (0.00 sec) mysql> select user,host from mysql.user; +------+---------------+ | user | host | +------+---------------+ | root | 127.0.0.1 | | | Mysql5-Server | | root | Mysql5-Server | | root | localhost | +------+---------------+ 4 rows in set (0.00 sec) mysql> drop user''@'Mysql5-Server'; Query OK, 0 rows affected (0.00 sec) mysql> select user,host from mysql.user; +------+---------------+ | user | host | +------+---------------+ | root | 127.0.0.1 | | root | Mysql5-Server | | root | localhost | +------+---------------+ 3 rows in set (0.00 sec) mysql> delete from mysql.user where user="" and host="Mysql5-Server"; 同上 mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) |
报错整理:
0 1 2 3 4 5 6 7 |
Q:checking for termcap functions library... configure: error: No curses/termcap library found A:[root@Mysql5-Server mysql-5.1.51]# yum install ncurses-devel –y Q:WARNING: The host 'Mysql5-Server' could not be looked up with resolveip. A:警告其实不影响,此处可以修改/etc/hosts对应127.0.0.1 Mysql5-Server Q:Starting MySQL... ERROR! Manager of pid-file quit without updating file. A:[root@Mysql5-Server bin]# cp /byrd/tools/mysql-5.1.51/support-files/my-small.cnf /etc/my.cnf Q:[root@Mysql5-Server bin]# mysql 提示:-bash: mysql: command not found A:[root@Mysql5-Server bin]# . ~/.bash_profile 增加:PATH=/usr/local/mysql/bin/:$PATH:$HOME/bin |
Mysql一键安装:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
#!/bin/sh #Compile and install MYSQL BY:BYRD AT:2014-04-30 #This script for MYSQL5.1.51 PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin export PATH # Check if user is root if [ $(id -u) != "0" ]; then echo "Error: You must be root to run this script, please use root to install lnmp" exit 1 fi /usr/bin/clear echo "=========================================================================" echo "Compile and install MYSQL BY:BYRD AT:2014-04-30" echo "=========================================================================" /bin/mkdir -p /byrd/tools /bin/mkdir /byrd/server /usr/sbin/useradd mysql -s /sbin/nologin -M yum install vim gcc gcc-c++ wget tree lsof ncurses-devel -y cd /byrd/tools && wget http://down1.chinaunix.net/distfiles/mysql-5.1.51.tar.gz && tar zxf mysql-5.1.51.tar.gz && cd mysql-5.1.51 ./configure --prefix=/byrd/server/mysql5.1.51 --with-unix-socket-path=/byrd/server/mysql5.1.51/tmp/mysql.sock --localstatedir=/byrd/server/mysql5.1.51/data --enable-assembler --enable-thread-safe-client --with-mysqld-user=mysql --with-big-tables --without-debug --with-pthread --enable-assembler --with-extra-charsets=complex --with-readline --with-ssl --with-embedded-server --enable-local-infile --with-plugins=partition,innobase --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static && make && make install ln -s /byrd/server/mysql5.1.51/ /usr/local/mysql mkdir -p /usr/local/mysql/data chown -R mysql /usr/local/mysql ln -s /byrd/server/mysql5.1.51/ /usr/local/mysql mkdir -p /usr/local/mysql/data chown -R mysql /usr/local/mysql /usr/local/mysql/bin/mysql_install_db --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/ --user=mysql && /bin/cp /byrd/tools/mysql-5.1.51/support-files/mysql.server /usr/local/mysql/bin/ chmod 755 /usr/local/mysql/bin/mysql.server /bin/cp /byrd/tools/mysql-5.1.51/support-files/my-small.cnf /etc/my.cnf cp /usr/local/mysql/bin/mysql.server /etc/init.d/mysqld service mysqld start netstat -tunlp|grep 3306 |
申明:本文由BYRD原创(基于Centos6.4 X64、Mysql5.1.51),未经许可禁止转载!SourceByrd's Weblog-https://note.t4x.org/database/config-mysql-database/ SourceByrd's Weblog-https://note.t4x.org/database/config-mysql-database/
申明:除非注明Byrd's Blog内容均为原创,未经许可禁止转载!详情请阅读版权申明!
Trackbacks