SuSE11安装MySQL5.6.40:编译安装方式、单实例-创新互联
摘要:SuSE11sp3 64位操作系统、 MySQL5.6.40 编译安装、单实例
浑江网站建设公司创新互联,浑江网站设计制作,有大型网站制作公司丰富经验。已为浑江上1000家提供企业网站建设服务。企业网站搭建\外贸营销网站建设要多少钱,请找那个售后服务好的浑江做网站的公司定做!注:kingtry是我的主机名
一、环境准备
操作系统:SuSE版本11sp3,64位
kingtry:~ # uname -a Linux kingtry 3.0.76-0.11-default #1 SMP Fri Jun 14 08:21:43 UTC 2013 (ccab990) x86_64 x86_64 x86_64 GNU/Linux kingtry:~ # cat /etc/SuSE-release SUSE Linux Enterprise Server 11 (x86_64) VERSION = 11 PATCHLEVEL = 3二、依赖包
tack-5.6-90.55.x86_64.rpm ncurses-devel-5.6-90.55.x86_64.rpm bison-2.3-127.112.x86_64.rpm三、编译安装cmake-2.8.4.tar.gz
kingtry:~ # tar -xf cmake-2.8.4.tar.gz kingtry:~ # cd cmake-2.8.4/ kingtry:~/cmake-2.8.4 # ./configure kingtry:~/cmake-2.8.4 # make && make install四、软件准备
mysql-5.6.40.tar.gz
五、安装过程
1、创建群组及用户
kingtry:~ # groupadd mysql kingtry:~ # useradd -g mysql mysql2、创建相关目录
kingtry:~ # mkdir -p /data/mysql/{data,tmp} #创建存放数据文件目录,data与tmp之间不能为空格 kingtry:~ # chown -R mysql.mysql /data/mysql3、解压文件,并修改解压后的文件夹的名称
kingtry:~ # tar -xf mysql-5.6.40.tar.gz4、编译安装
kingtry:~ # cd mysql-5.6.40/ kingtry:~/mysql-5.6.40 # cmake . -DCMAKE_INSTALL_PREFIX=/root/mysql \ -DSYSCONFDIR=/data/mysql \ -DMYSQL_DATADIR=/data/mysql/data \ -DMYSQL_UNIX_ADDR=/data/mysql/mysql.sock \ -DMYSQL_TCP_PORT=3306 \ -DWITH_ARCHIVE_STORAGE_ENGINE=1 \ -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ -DWITH_PARTITION_STORAGE_ENGINE=1 \ -DENABLED_LOCAL_INFILE=1 \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DEXTRA_CHARSETS=all kingtry:~/mysql-5.6.40 # make && make install六、初始化数据库
注:此处不能使用安装文件下的同名文件(不能使用/root/mysql-5.6.40/scripts/mysql_install_db)
kingtry:~ # /root/mysql/scripts/mysql_install_db --basedir=/root/mysql --datadir=/data/mysql/data --user=mysql七、创建配置文件/data/mysql/my.cnf
my.cnf内容参考如下:
# For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html [client] #password = your_password port = 3306 socket = /data/mysql/mysql.sock default-character-set=utf8 # Here follows entries for some specific programs # The MySQL server [mysqld] port = 3306 basedir = /root/mysql datadir = /data/mysql/data tmpdir = /data/mysql/tmp socket = /data/mysql/mysql.sock character-set-server = utf8 collation-server = utf8_general_ci pid-file = /data/mysql/mysql.pid user = mysql explicit_defaults_for_timestamp lower_case_table_names = 1 max_connections = 1000 back_log = 1024 open_files_limit = 10240 table_open_cache = 5120 #bind-address = 127.0.0.1 #skip-name-resolve skip-external-locking local-infile = 1 key_buffer_size = 32M max_allowed_packet = 1M table_open_cache = 64 sort_buffer_size = 512K net_buffer_length = 8K read_buffer_size = 256K read_rnd_buffer_size = 512K myisam_sort_buffer_size = 8M # Don't listen on a TCP/IP port at all. This can be a security enhancement, # if all processes that need to connect to mysqld run on the same host. # All interaction with mysqld must be made via Unix sockets or named pipes. # Note that using this option without enabling named pipes on Windows # (via the "enable-named-pipe" option) will render mysqld useless! # #skip-networking # Replication Master Server (default) # binary logging is required for replication log-bin = /data/mysql/mysql-bin # binary logging format - mixed recommended binlog_format = mixed # required unique id between 1 and 2^32 - 1 # defaults to 1 if master-host is not set # but will not function as a master if omitted server-id = 1 # Replication Slave (comment out master section to use this) # # To configure this host as a replication slave, you can choose between # two methods : # # 1) Use the CHANGE MASTER TO command (fully described in our manual) - # the syntax is: # # CHANGE MASTER TO MASTER_HOST=八、配置环境变量
kingtry:~ # echo 'export PATH=/root/mysql/bin:$PATH' >> /etc/profile kingtry:~ # source /etc/profile九、启动MySQL服务
kingtry:~ # touch /data/mysql/mysql.err #当前版本该文件不会自动创建,需要手工创建 kingtry:~ # chown mysql.mysql /data/mysql/mysql.err kingtry:~ # mysqld_safe --defaults-file=/data/mysql/my.cnf --user=mysql &十、安装后配置之root密码修改
默认情况下root密码为空,这在生产环境下肯定不行的。修改root密码的方式有以下两种,随便哪个都行:
1、命令方式(注:首次修改密码,修改前密码为空)
kingtry:~ # mysqladmin -u root password 'root123'要注意如果执行以上步骤之后root密码已经不为空,如果此时想再次修改root密码,上面命令就不行了,需要用到下面的命令:
kingtry:~ # mysqladmin -u root -p password 'root1234' Enter password:这是交互式方式修改,输入的当前密码,password参数后面跟随的是想要修改成的密码
十一、客户端连接MySQL服务
kingtry:~ # mysql -uroot -p十二、防火墙允许3306端口
kingtry:~ # vi /etc/sysconfig/SuSEfirewall2在FW_SERVICES_EXT_TCP增加3306端口,如果存在其他端口,则空格隔开,如:
FW_SERVICES_EXT_TCP="21 22 3306"重启防火墙:
kingtry:~ # rcSuSEfirewall2 restart十三、设置远程访问
先登陆mysql服务器,授权root用户可以远程登陆
mysql> grant all PRIVILEGES on *.* to root@'%' identified by 'root123'; Query OK, 0 rows affected (0.00 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) mysql>注:生产环境最好只允许root在特定IP的机器上才能远程访问。
另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
分享文章:SuSE11安装MySQL5.6.40:编译安装方式、单实例-创新互联
本文地址:http://hbruida.cn/article/dseigh.html