环境:centos7.0
一、查看环境:
1、查看网卡:
ifconfig -a
2、查看操作系统:
cat /etc/redhat-release
3、查看内核:
uname -r
4、查看操作系统是32/64位的:
uname -m
二、安装相关包:
2.1 cmake软件
cd /home/test/tools/
rz -y(目的是传输win下已下载好的软件包)
tar xf cmake-2.8.8.tar.gz(解压cmake压缩包)
cd cmake-2.8.8
./configure
gmake install(强调用root用户,其他用户会报权限的问题)
cd ../
2.2依赖包
yum install ncurses-devel -y
出现这个问题:Could not resolve host: mirrorlist.centos.org; 未知的错误(换一个yum源,或者是你的网络处于桥接模式换成NAT模式能连接外网即可)
出现/var/run/yum.pid 已被锁定,PID 为 45726 的另一个程序正在运行这个错误,解决:rm -f /var/run/yum.pid 然后再输入yum依赖包;
三、开始安装mysql
3.1创建用户和组:
groupadd mysql
useradd mysql -s /sbin/nologin -M -g mysql
3.2解压编译mysql:
rz -y
tar xf mysql-5.5.32.tar.gz
cd mysql-5.5.32
cmake . -DCMAKE_INSTALL_PREFIX=/application/mysql-5.5.32 \
-DMYSQL_DATADIR=/application/mysql-5.5.32/data \
-DMYSQL_UNIX_ADDR=/application/mysql-5.5.32/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
which cmake
ln -s /application/mysql-5.5.32/ /application/mysql
cp mysql-5.5.32/support-files/my-small.cnf /etc/my.cnf(在tools目录下,这一步是选择配置文件)
echo 'export PATH=/application/mysql/bin:$PATH' >>/etc/profile
tail -l /etc/profile
source /etc/profile
echo $PATH(这4步是配置环境变量)
ll /application/mysql/data/
chown -R mysql.mysql /application/mysql/data/
chmod -R 1777 /tmp/
初始化:
cd /application/mysql/scripts/
./mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data --user=mysql(出现两个ok表示初始化成功)
/bin/cp support-files/mysql.server /etc/init.d/mysqld(在/home/test/tools/mysql-5.5.32下把这个mysql启动脚本拷贝到init.d下,并重命名mysqld)
chmod +x /etc/init.d/mysqld
/etc/init.d/mysqld start(启动mysql)
netstat -lntup|grep 3306
四、登录mysql故障解决:
ERROR1045(28000)
pkill mysqld
lsof -i :3306
rm -rf /application/mysql/data/*
/application/mysql/scripts/mysql_install_db --basedir=/application/mysql/
五、优化:
1、select user,host from mysql.user;
delete from mysql.user where user='';
delete from mysql.user where host='ACER.localdomain';(ACER.localdomain是上述列表里面的某一个主机名)
delete from mysql.user where host='::1';
drop database test;
show databases;
2、为mysql增加密码(exit出mysql):
/application/mysql//bin/mysqladmin -u root password 'zdh123';
vi /etc/sysconfig/il8n(修改字符集):
LANG="zh_CN.UTF-8"并且在CRT选项-会话选项-外观-字符编码统一改成UTF-8
. /etc/sysconfig/il8n
mysql -uroot -zdh123
3、chkconfig mysqld on
一、查看环境:
1、查看网卡:
ifconfig -a
2、查看操作系统:
cat /etc/redhat-release
3、查看内核:
uname -r
4、查看操作系统是32/64位的:
uname -m
二、安装相关包:
2.1 cmake软件
cd /home/test/tools/
rz -y(目的是传输win下已下载好的软件包)
tar xf cmake-2.8.8.tar.gz(解压cmake压缩包)
cd cmake-2.8.8
./configure
gmake install(强调用root用户,其他用户会报权限的问题)
cd ../
2.2依赖包
yum install ncurses-devel -y
出现这个问题:Could not resolve host: mirrorlist.centos.org; 未知的错误(换一个yum源,或者是你的网络处于桥接模式换成NAT模式能连接外网即可)
出现/var/run/yum.pid 已被锁定,PID 为 45726 的另一个程序正在运行这个错误,解决:rm -f /var/run/yum.pid 然后再输入yum依赖包;
三、开始安装mysql
3.1创建用户和组:
groupadd mysql
useradd mysql -s /sbin/nologin -M -g mysql
3.2解压编译mysql:
rz -y
tar xf mysql-5.5.32.tar.gz
cd mysql-5.5.32
cmake . -DCMAKE_INSTALL_PREFIX=/application/mysql-5.5.32 \
-DMYSQL_DATADIR=/application/mysql-5.5.32/data \
-DMYSQL_UNIX_ADDR=/application/mysql-5.5.32/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
which cmake
ln -s /application/mysql-5.5.32/ /application/mysql
cp mysql-5.5.32/support-files/my-small.cnf /etc/my.cnf(在tools目录下,这一步是选择配置文件)
echo 'export PATH=/application/mysql/bin:$PATH' >>/etc/profile
tail -l /etc/profile
source /etc/profile
echo $PATH(这4步是配置环境变量)
ll /application/mysql/data/
chown -R mysql.mysql /application/mysql/data/
chmod -R 1777 /tmp/
初始化:
cd /application/mysql/scripts/
./mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data --user=mysql(出现两个ok表示初始化成功)
/bin/cp support-files/mysql.server /etc/init.d/mysqld(在/home/test/tools/mysql-5.5.32下把这个mysql启动脚本拷贝到init.d下,并重命名mysqld)
chmod +x /etc/init.d/mysqld
/etc/init.d/mysqld start(启动mysql)
netstat -lntup|grep 3306
四、登录mysql故障解决:
ERROR1045(28000)
pkill mysqld
lsof -i :3306
rm -rf /application/mysql/data/*
/application/mysql/scripts/mysql_install_db --basedir=/application/mysql/
五、优化:
1、select user,host from mysql.user;
delete from mysql.user where user='';
delete from mysql.user where host='ACER.localdomain';(ACER.localdomain是上述列表里面的某一个主机名)
delete from mysql.user where host='::1';
drop database test;
show databases;
2、为mysql增加密码(exit出mysql):
/application/mysql//bin/mysqladmin -u root password 'zdh123';
vi /etc/sysconfig/il8n(修改字符集):
LANG="zh_CN.UTF-8"并且在CRT选项-会话选项-外观-字符编码统一改成UTF-8
. /etc/sysconfig/il8n
mysql -uroot -zdh123
3、chkconfig mysqld on