首页 > 代码库 > Linux下安装mysql
Linux下安装mysql
安装系统所需要的依赖包
[root@namenode ~]# yum -y install gcc gcc-c++ gcc-g77 autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel* cmake bison
创建mysql用户与用户组
[root@namenode ~]# groupadd mysql
[root@namenode ~]# useradd -r -g mysql mysql
安装mysql
[root@namenode ~]# tar zxvf mysql-5.5.25.tar.gz
[root@namenode ~]# cd mysql-5.5.25
[root@namenode mysql-5.5.25]# cmake -DCMAKE_INSTALL_PREFIX=/opt/mysql/ -DMYSQL_DATADIR=/opt/mysql/data -DMYSQL_UNIX_ADDR=/opt/mysql/data/mysqld.sock -DWITH_INNOBASE_STORAGE_ENGINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_TCP_PORT=3306 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DMYSQL_UNIX_ADDR=/opt/mysql/data/mysql.sock -DMYSQL_USER=mysql -DWITH_DEBUG=0
[root@namenode mysql-5.5.25]# make && make install
赋予相关权限
[root@namenode mysql-5.5.25]# chown -R mysql:mysql /opt/mysql
[root@namenode mysql-5.5.25]# /opt/mysql/scripts/mysql_install_db --user=mysql --basedir=/opt/mysql --datadir=/opt/mysql/data
mysql配置文件
[root@namenode mysql-5.5.25]# cp /opt/mysql/support-files/my-large.cnf /etc/my.cnf
[root@namenode mysql-5.5.25]# cp /opt/mysql/support-files/mysql.server /etc/init.d/mysql
[root@namenode mysql-5.5.25]# chmod +x /etc/init.d/mysql
增加自动启动
[root@namenode mysql-5.5.25]# chkconfig mysql on
启动mysql
[root@namenode mysql-5.5.25]# /etc/init.d/mysql start
Starting MySQL...... [ OK ]
查看mysql 的3306端口,看到下面说明启动成功
[root@namenode mysql-5.5.25]#ps aux | grep 3306
mysql 17237 3.6 8.4 615660 86264 pts/2 Sl 22:10 0:01 /opt/mysql/bin/mysqld --basedir=/opt/mysql --datadir=/opt/mysql/data --plugin-dir=/opt/mysql/lib/plugin --user=mysql --log-error=/opt/mysql/data/namenode.err --pid-file=/opt/mysql/data/namenode.pid --socket=/opt/mysql/data/mysql.sock --port=3306
root 17798 0.0 0.0 61228 784 pts/2 S+ 22:10 0:00 grep 3306
设置mysql初始密码,123456是密码,你可以设置自己需要的密码
[root@namenode mysql-5.5.25]# /opt/mysql/bin/mysqladmin -u root password ‘123456‘
[root@namenode mysql-5.5.25]# /opt/mysql/bin/mysql -uroot -p123456
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.25-log Source distribution
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.
mysql>
以上说明成功了
本文出自 “飛鴻沓膤” 博客,请务必保留此出处http://jxzhfei.blog.51cto.com/1382161/1441329
Linux下安装mysql