MSYQL安装配置
来源:互联网 发布:中国怎么没抓达喇 知乎 编辑:程序博客网 时间:2024/06/08 10:24
1.1.1. Mysql
需要软件
cmake-2.8.4.tar.gz
mysql-5.5.16.tar.gz
配置内核参数
1 在文件/etc/sysctl.conf配置
kernel.shmmax = 68719476736
# Controls the maximum number of shared memory segments, in pages
kernel.shmall = 17179869184
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 6553600
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
2.在root用户下运行命令
/sbin/sysctl -p
net.ipv4.ip_forward = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
net.ipv4.tcp_syncookies = 1
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.shmmax = 68719476736
kernel.shmall = 17179869184
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 6553600
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
3.重新核查以上操作在两个节点
限制操作
1. 在/etc/security/limits.conf添加如下内容
* soft nproc 5047
* hard nproc 16384
* soft nofile 100000
* hard nofile 65536
2. 在/etc/pam.d/login添加如下内容
session required pam_limits.so
3. 修改/etc/selinux/config如下内容
SELINUX=disabled
etenforce 0
上传及安装cmake软件
[root@SR3 soft]# tar -zxvf cmake-2.8.4.tar.gz
[root@SR3 soft]# cd cmake-2.8.4
[root@SR3 cmake-2.8.4]# ./configure
[root@SR3 ~]# make
[root@SR3 ~]# make install
创建目录及mysql用户及分配权限
[root@SR3 cmake-2.8.4]# mkdir -p /opt/mysql/data
[root@SR3 cmake-2.8.4]# groupadd -g 501 mysql
[root@SR3 cmake-2.8.4]# useradd -u 501 -g 501 mysql
[root@SR3 cmake-2.8.4]# id mysql
uid=501(mysql) gid=501(mysql) groups=501(mysql)
[root@SR3 cmake-2.8.4]# passwd mysql
Changing password for user mysql.
New UNIX password:
BAD PASSWORD: it is too short
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[root@SR3 cmake-2.8.4]# chown -R mysql:mysql /opt/mysql /opt/soft
注:设置密码为mysql
1.1.2. 安装配置MYSQL
Mysql安装
切换到mysql用户下:
[mysql@SR3 soft]$ tar -zxvf mysql-5.5.16.tar.gz
[mysql@SR3 soft]$ cd mysql-5.5.16
需要root用户进行安装
[root@SR3 mysql-5.5.16]# cmake -DCMAKE_INSTALL_PREFIX=/opt/mysql -DSYSCONFDIR=/opt/mysql/etc -DMYSQL_DATADIR=/data/mysql/data -DMYSQL_TCP_PORT=3306 -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock -DMYSQL_USER=mysql -DEXTRA_CHARSETS=all -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITHOUT_PARTITION_STORAGE_ENGINE=1
……
-- Looking for tputs in /usr/lib64/libcurses.so
-- Looking for tputs in /usr/lib64/libcurses.so - found
-- Looking for include files HAVE_LIBAIO_H
-- Looking for include files HAVE_LIBAIO_H - found
-- Looking for io_queue_init in aio
-- Looking for io_queue_init in aio - found
-- Performing Test HAVE_IB_GCC_ATOMIC_BUILTINS
-- Performing Test HAVE_IB_GCC_ATOMIC_BUILTINS - Success
-- Performing Test HAVE_IB_ATOMIC_PTHREAD_T_GCC
-- Performing Test HAVE_IB_ATOMIC_PTHREAD_T_GCC - Success
-- Check size of pthread_t
-- Check size of pthread_t - done
-- Performing Test HAVE_PEERCRED
-- Performing Test HAVE_PEERCRED - Success
Warning: Bison executable not found in PATH
-- Configuring done
-- Generating done
CMake Warning: The variable, 'MYSQL_USER', specified manually, was not used during the generation.
-- Build files have been written to: /opt/soft/mysql-5.5.16
[root@SR3 ~]# make
…
[ 99%] Built target mysql_embedded
Scanning dependencies of target mysqltest_embedded
[100%] Building CXX object libmysqld/examples/CMakeFiles/mysqltest_embedded.dir/__/__/client/mysqltest.cc.o
Linking CXX executable mysqltest_embedded
[100%] Built target mysqltest_embedded
Scanning dependencies of target my_safe_process
[100%] Building CXX object mysql-test/lib/My/SafeProcess/CMakeFiles/my_safe_process.dir/safe_process.cc.o
Linking CXX executable my_safe_process
[100%] Built target my_safe_process
[root@SR3 ~]# make install
….
Installing: /opt/mysql/man/man1/perror.1
-- Installing: /opt/mysql/man/man1/myisamchk.1
-- Installing: /opt/mysql/man/man1/mysql_waitpid.1
-- Installing: /opt/mysql/man/man1/replace.1
-- Installing: /opt/mysql/man/man1/mysqlhotcopy.1
-- Installing: /opt/mysql/man/man1/mysqlaccess.1
-- Installing: /opt/mysql/man/man1/mysql_setpermission.1
-- Installing: /opt/mysql/man/man1/mysqltest.1
-- Installing: /opt/mysql/man/man8/mysqld.8
注:安装完成!
创建my.cnf配置文件
创建my.cnf配置文件
[root@SR3 mysql]# pwd
/opt/mysql
[root@SR3 mysql]# mkdir log
[root@SR3 mysql]# mkdir etc
[root@SR3 mysql]# cp support-files/my-medium.cnf /opt/mysql/etc/my.cnf
初始化数据库
[root@SR3 mysql]# chmod 755 scripts/mysql_install_db
[root@SR3 mysql]# scripts/mysql_install_db --user=mysql --basedir=/opt/mysql/ --datadir=/data/mysql/data/
WARNING: The host 'SR3' could not be looked up with resolveip.
This probably means that your libc libraries are not 100 % compatible
with this binary MySQL version. The MySQL daemon, mysqld, should work
normally with the exception that host name resolving will not work.
This means that you should use IP addresses instead of hostnames
when specifying MySQL privileges !
Installing MySQL system tables...
OK
Filling help tables...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/opt/mysql//bin/mysqladmin -u root password 'new-password'
/opt/mysql//bin/mysqladmin -u root -h SR3 password 'new-password'
Alternatively you can run:
/opt/mysql//bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /opt/mysql/ ; /opt/mysql//bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /opt/mysql//mysql-test ; perl mysql-test-run.pl
Please report any problems with the /opt/mysql//scripts/mysqlbug script!
创建数据库shell脚本
[root@SR3 mysql]# mkdir /opt/mysql/init.d
[root@SR3 mysql]# pwd
/opt/mysql
[root@SR3 mysql]# cp support-files/mysql.server /opt/mysql/init.d/mysql
启动mysql数据库
[root@SR3 mysql]# chmod +x /opt/mysql/init.d/mysql
[root@SR3 mysql]# /opt/mysql/init.d/mysql start
Starting MySQL....[ OK ]
注:启动成功。
设置mysql数据库环境变量
编写文件.bash_profile,添加如下代码
MYSQL_HOME=/opt/mysql
export MYSQL_HOME
PATH=$MYSQL_HOME/bin:$PATH
设置mysql数据库root密码
[mysql@SR3 ~]$ mysqladmin -u root password 'geelygap'
[mysql@SR3 ~]$ mysql -h 10.86.87.155 -uroot -pgeelygap
ERROR 1130 (HY000): Host '10.86.87.155' is not allowed to connect to this MySQL server
[mysql@SR3 ~]$ mysql -h 127.0.0.1 -uroot -pgeelygap
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.5.16-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>
解决方案:
[root@SR3 mysql]# vi /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
10.86.87.155 SR3
注:配置主机名,重启mysql 服务。
[mysql@SR3 ~]$ mysql -h 10.86.87.155
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 5.5.16-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>
mysql> update user set password=PASSWORD("geely123") where user="root";
ERROR 1046 (3D000): No database selected
mysql> use mysql;
Database changed
mysql> update user set password=PASSWORD("geelygap") where user="root";
Query OK, 3 rows affected (0.00 sec)
Rows matched: 4 Changed: 3 Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye
[mysql@SR3 ~]$ mysql -h 10.86.87.155 -uroot -pgeelygap
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 5.5.16-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> exit
设置mysql数据库开机启动
[root@SR3 mysql]# cp /opt/mysql/init.d/mysql /etc/init.d/mysql
[root@SR3 mysql]# chmod 755 /etc/init.d/mysql
[root@SR3 mysql]# chkconfig mysql on
注:此时mysql安装完成。
- MSYQL安装配置
- Ubuntu安装配置msyql
- centos 6.3 msyql安装配置
- 配置和管理msyql
- msyql + php 安装备忘
- win10安装msyql
- ubuntu14下 安装msyql
- msyql慢查询日志配置
- centos下配置 msyql数据库
- CentOS 6.5 yum 安装msyql
- msyql
- ubuntu下-配置和管理msyql
- Linux配置和管理msyql命令
- centos7安装jdk,tomcat,msyql(MariaDB)
- msyql 关于数据库的安装和操作
- msyql 5.7.20安装与登录
- 读《msyql完全手册》之一:介绍和安装
- msyql安装到最后一步start service出错的方法
- 文本相似度计算-JaccardSimilarity和哈希签名函数
- 线程 and 多线程中sleep()、wait()方法等得区别?
- ListView的反弹效果的实现(一)
- AE二次开发,右键图层,设置图层要素标注
- UPUPW PHP环境集成包,增加多个PHP版本支持,可选择使用
- MSYQL安装配置
- 密码
- cocos2d 学习
- CSS3中的动画功能之笔记
- TTL电平与CMOS电平
- uva133 利用指针编写双向循环链表
- cocos2d-x进度条读取
- ScrollView的反弹效果的实现
- 网页游戏打击感实施要点