标签:
[root@mysql ~]# cat /etc/redhat-release
CentOS release 6.6 (Final)
[root@mysql ~]# uname -r
2.6.32-504.el6.x86_64
[root@mysql ~]# uname -m
x86_64
yum groupinstall "Base" "Compatibility libraries" "Development tools" "Dial-up Networking Support" "Performance Tools" "Performance Tools"
yum install mysql-server
# 2.1 创建用户与mysql数据存放目录
useradd -M -s /sbin/nologin mysql
mkdir /data
chown mysql.mysql /data
# 2.2 安装必要包,下载解压
yum install ncurses-devel -y #没安装包会有这个报错:checking for termcap functions library... configure: error: No curses/termcap library found
mkdir /home/test
cd /home/test/tools
wget http://cdn.mysql.com/Downloads/MySQL-5.1/mysql-5.1.73.tar.gz
tar xf mysql-5.1.73.tar.gz
cd mysql-5.1.73
# 2.3 生成Makefile,编译,安装
./configure \
--prefix=/application/mysql-5.1.73 \
--with-unix-socket-path=/application/mysql-5.1.73/tmp/mysql.sock \
--localstatedir=/application/mysql-5.1.73/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 -j 2 && make install
# 提示:可以通过 echo $? 来查看编译安装过程中是否出错
# 2.4 对mysql-5.1.73创建软连接
ln -s /application/mysql-5.1.73/ /application/mysql
# 2.5 提供配置文件
\cp /application/mysql/share/mysql/my-large.cnf /etc/my.cnf
#在mysqld中添加 skip_name_resolve =on innodb_file_per_table = on
# 2.6 初始化mysql
/application/mysql/bin/mysql_install_db --basedir=/application/mysql --datadir=/data/ --user=mysql
# 2.7 提供 SysV 脚本
cp /application/mysql/share/mysql/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
# 修改basedir和datadir
sed -i ‘46s#\(basedir=\).*#\1/application/mysql#‘ /etc/rc.d/init.d/mysqld
sed -i ‘47s#\(datadir=\).*#\1/data#‘ /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld off
chkconfig --list mysqld
# 2.8 启动mysql
/etc/init.d/mysqld start
# 2.9 将mysql的路径加入环境变量
echo "PATH=/application/mysql/bin/:$PATH" > /etc/profile.d/mysql.sh
source /etc/profile.d/mysql.sh
# 2.10 输出mysql的库文件给系统的查找路径
echo ‘/application/mysql/lib‘ > /etc/ld.so.conf.d/mysql.conf
ldconfig
# 2.11 输出mysql的头文件至系统头文件路径
ln -s /application/mysql/include/mysql/ /usr/include/mysql
# 2.12 将编译的软件man手册加入系统
cat >> /etc/man.config << EOF
# start 20150705 by test
MANPATH /application/mysql/share/man
# end 20150705 by test
EOF
# 2.1 创建用户与mysql数据存放目录
useradd -M -s /sbin/nologin mysql
mkdir /data
chown mysql.mysql /data
# 2.2 安装必要包,下载解压
yum install cmake ncurses-devel -y
wget http://mirrors.opencas.cn/mariadb/mariadb-5.5.44/source/mariadb-5.5.44.tar.gz
tar xf mariadb-5.5.44
cd mariadb-5.5.44
# 2.3 编译安装(cmake --> make --> make install)
cmake . \
-DCMAKE_INSTALL_PREFIX=/application/mariadb-5.5.44 \
-DMYSQL_DATADIR=/data \
-DMYSQL_UNIX_ADDR=/application/mariadb-5.5.44/tmp/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii \
-DENABLED_LOCAL_INFILE=ON \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
-DWITHOUT_PARTITION_STORAGE_ENGINE=1 \
-DWITH_FAST_MUTEXES=1 \
-DWITH_ZLIB=bundled \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_READLINE=1 \
-DWITH_EMBEDDED_SERVER=1 \
-DWITH_DEBUG=0
make -j 4 && make install
# 2.4 创建软连接
ln -s /application/mariadb-5.5.44/ /application/mariadb
# 2.5 提供配置文件
cd /application/mariadb/
\cp support-files/my-large.cnf /etc/my.cnf
# 2.6 初始化 mariadb
scripts/mysql_install_db --user=mysql --basedir=/application/mariadb/ --datadir=/data/
# 2.7 提供 SysV 脚本
cp support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
# 2.8 启动 mariadb
/etc/init.d/mysqld start
# 2.9 将 mariadb 的路径加入环境变量
echo "PATH=/application/mariadb/bin:$PATH" > /etc/profile.d/mysql.sh
source /etc/profile.d/mysql.sh
# 2.10 输出 mariadb 的库文件给系统的查找路径
echo ‘/application/mariadb/lib/‘ > /etc/ld.so.conf.d/mysql.conf
ldconfig
# 2.11 输出 mariadb 的头文件至系统头文件路径
ln -s /application/mariadb/include/mysql/ /usr/include/mysql
# 2.12 将编译的软件man手册加入系统
cat >> /etc/man.config << EOF
# start 20150705 by test
MANPATH /application/mariadb/man/
# end 20150705 by test
EOF
# 2.1 创建用户与mysql数据存放目录
useradd -M -s /sbin/nologin mysql
mkdir /data
chown mysql.mysql /data
# 2.2 下载解压并移动到指定目录
mkdir /home/test
cd /home/test/
wget http://mirrors.opencas.cn/mariadb/mariadb-5.5.44/bintar-linux-glibc_214-x86_64/mariadb-5.5.44-x86_64.tar.gz
tar xf mariadb-5.5.44-linux-x86_64.tar.gz
mkdir /application
mv mariadb-5.5.44-linux-x86_64 /application
# 2.3 对创建软连接
ln -s /application/mariadb-5.5.44-linux-x86_64 /application/mariadb
# 2.4 初始化mariadb
cd /application/mariadb
scripts/mysql_install_db --user=mysql --basedir=/application/mariadb --datadir=/data/
# 2.5 提供配置文件
\cp /application/mariadb/support-files/my-large.cnf /etc/my.cnf
# 2.6 提供 SysV 脚本
cp /application/mariadb/support-files/mysql.server /etc/init.d/mysqld
sed -i ‘46s#\(basedir=\).*#\1/application/mariadb#‘ /etc/rc.d/init.d/mysqld
sed -i ‘47s#\(datadir=\).*#\1/data#‘ /etc/rc.d/init.d/mysqld
chmod +x /etc/init.d/mysqld
# 2.7 提供环境变量
echo "PATH=/application/mariadb/bin/:$PATH" > /etc/profile.d/mysql.sh
source /etc/profile.d/mysql.sh
# 2.8 启动mysql
/etc/init.d/mysqld start
# 登陆
mysql
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
MariaDB [(none)]> select user,host from mysql.user;
+------+-----------+
| user | host |
+------+-----------+
| root | 127.0.0.1 |
| root | ::1 |
| | localhost |
| root | localhost |
| | mysql |
| root | mysql |
+------+-----------+
6 rows in set (0.03 sec)
# 删除多余的库和用户
mysql -e "drop database test;"
mysql -e "drop user ‘root‘@‘::1‘;"
mysql -e "drop user ‘‘@‘localhost‘"
mysql -e "delete from mysql.user where user=‘‘ and host=‘mysql‘;"
mysql -e "delete from mysql.user where user=‘root‘ and host=‘mysql‘;"
mysql -e "select user,host from mysql.user;"
mysql -e "show databases;"
# 设置密码
mysqladmin -u root password ‘123‘
# 设置完密码再次登陆
mysql -uroot -p123 -hlocalhost
# 修改密码
mysqladmin -u root -p123 password 123456
标签:
原文地址:http://www.cnblogs.com/kwstars/p/4f82462b7fb8c6106e662ebc6549e0c6.html