安装mysql,安装前准备
如果mysql用户不存在,那么添加mysql用户
groupadd mysql
useradd -g mysql mysql
mysql编译安装
tar -zxvf mysql-5.1.73.tar.gz
cd mysql-5.1.73
yum install ncurses ncurses-devel
./configure '--prefix=/usr/local/mysql' '--without-debug' '--with-charset=utf8' '--with-extra-charsets=all' '--enable-assembler' '--with-pthread' '--enable-thread-safe-client' '--with-mysqld-ldflags=-all-static' '--with-client-ldflags=-all-static' '--with-big-tables' '--with-readline' '--with-ssl' '--with-embedded-server' '--enable-local-infile' '--with-plugins=innobase'
make
make install
到此mysql就安装到了/usr/local/mysql路径下,下面开始mysql的配置工作
安装mysql选项文件
cp support-files/my-medium.cnf /etc/my.cnf
cp -r support-files/mysql.server /etc/init.d/mysql
/sbin/chkconfig --del mysql
/sbin/chkconfig --add mysql
配置权限表
chown -R mysql:mysql /usr/local/mysql
/usr/local/mysql/bin/mysql_install_db --user=mysql
启动mysql
给/etc/init.d/mysql 执行权限,然后运行
chmod a+wrx /etc/init.d/mysql
/etc/init.d/mysql start
mysql初始化配置:
包括密码设置等
export PATH=/usr/local/mysql/bin:$PATH
/usr/local/mysql/bin/mysql_secure_installation
在弹出的对话框中要求输入密码:
Enter current password for root (enter for none):
默认打回车,然后重新设置root密码:
设置root密码? [Y / n]和
Set root password? [Y/n] y
通常,仅应允许root从'localhost'连接。 这个
确保某人无法猜测来自网络的root密码。
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
禁止远程root登录? [是/否]
Disallow root login remotely? [Y/n] n
默认情况下,MySQL带有一个名为“ test”的数据库,任何人都可以
访问。 这也仅用于测试,在进入生产环境之前应删除
By default, MySQL comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
删除测试数据库并访问它? [是/否] n
Remove test database and access to it? [Y/n] n
重新加载特权表将确保到目前为止所做的所有更改
将立即生效。
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y
至此,Mysql运行成功
第五步,添加服务和启动项以及修改默认存储引擎:
添加服务:
1 cp support-files/mysql.server /etc/init.d/mysql.server #将mysql的启动服务添加到系统服务中
2 chmod u+x /etc/init.d/mysql.server #这步很必要,否则可能启动服务时提示没有权限。
3 service mysql.server start #启动
4 service mysql.server stop #停止
5 service mysql.server restart #重启
6 service mysql.server status #状态
添加启动项:
1 sudo chkconfig --level 23 mysql on #设定启动,在运行级别为2和3时
修改该存储引擎
vim /etc/my.cnf
在[mysqld] 下面加入default-storage-engine=INNODB,保存。
遇到的错误:
在安装之后,使用mysqld_safe脚本直接启动遇到如下错误。
‘–skip-locking’ is deprecated and will be removed in a future release. Please use ‘–skip-external-locking’ instead.
解决方法:
将/etc/my.cnf里面的skip-locking 改为skip-external-locking
安装mysql时,出现checking for termcap functions library... configure: error: No curses/termcap library found
解决办法:
下载安装相应软件包
一、系统是RedHat系列:
yum list|grep ncurses
yum -y install ncurses-devel
yum install ncurses-devel
二、系统是Ubuntu或Debian:
apt-cache search ncurses
apt-get install libncurses5-dev
三
#./configure \
--prefix=/usr/local/mysql \
--with-extra-charsets=all
# make && make install
——————————————