标签:
由于MySQL的版本不同,所以会有不同的安装方式。在下以Linux系统下MySQL5.1.19版本为例,进行安装,初学还望指正。
一、安装编译软件(简单的yum安装)
gcc
gcc-c++
ncurses
ncurses-devel
cmake
二、修改hosts可以解析主机名
echo "127.0.0.1 `hostname`" >> /etc/hosts
三、编译安装
# tar xvf mysql-5.5.19.tar.gz
# cd mysql-5.5.19
# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DMYSQL_UNIX_ADDR=/usr/local/mysql/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 && make install
四、生成配置文件
# cp /root/mysql-5.5.19/support-files/my-large.cnf /etc/my.cnf
# vim /etc/my.cnf
[mysqld]
datadir = /usr/local/mysql/data
五、新建一个运行MySQL的用户
# groupadd mysql
# useradd -r -g mysql -s /sbin/nologin mysql
六、初始化
#/home/mysql-5.5.19/scripts/mysql_install_db \
--basedir=/usr/local/mysql/ \
--datadir=/usr/local/mysql/data --user=mysql
七、修改MySQL目录权限
# chown -R root.mysql /usr/local/mysql
# chmod -R 777 /usr/local/mysql/data
八、启动MySQL
# /usr/local/mysql/bin/mysqld_safe --user=mysql &
九、导出启动程序
# cp /home/mysql-5.5.19/support-files/mysql.server /etc/init.d/mysqld
# chymod +x /etc/init.d/mysqld
# chkconfig --add mysqld
# service mysqld start
十、导出MySQL的登录程序
# ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
PS:
登录MySQL:
/usr/bin/mysql -u root -p密码
标签:
原文地址:http://www.cnblogs.com/xiaoxiangyucuo/p/5568143.html