Mysql 数据库二进制安装法及错误排查

一、二进制安装mysql数据库方法:

[root@mobana tools]#tar xf mysql-5.5.32-linux2.6-x86_64.tar.gz   <== 减压mysql安装包;

[root@mobana tools]# ls

mysql-5.5.32-linux2.6-x86_64   mysql-5.5.32-linux2.6-x86_64.tar.gz

[root@mobana tools]# mv mysql-5.5.32-linux2.6-x86_64 /application/mysql-5.5.32    <== 移动文件并更改名称为mysql-5.5.32

[root@mobana tools]# cd /application/

[root@mobana application]# ls

mysql-5.5.32

[root@mobana application]# ln -s mysql-5.5.32/ mysql/    <== 创建软链接;

[root@mobana application]# ll

4

lrwxrwxrwx  1 root root   13 126 05:34mysql -> mysql-5.5.32/

drwxr-xr-x 13 root root 4096 126 05:33 mysql-5.5.32

lrwxrwxrwx  1 root root   25 125 15:40 nginx -> /application/nginx-1.6.3/

drwxr-xr-x 11 root root 4096 125 15:43 nginx-1.6.3

[root@mobana mysql]# /bin/cp support-files/my-small.cnf  /etc/my.cnf      <== 初始化mysql配置文件my.cnf;

[root@mobana mysql]# mkdir -p /application/mysql/data/

[root@mobana mysql]# chown -R mysql.mysql /application/mysql      <== 初始化mysql配置文件my.cnf;

[root@mobana mysql]#/application/mysql/scripts/mysql_install_db --basedir=/application/mysql --

datadir=/application/mysql/data/ --user=mysql              <== 初始化mysql文件;

[root@mobana mysql]# cp support-files/mysql.server /etc/init.d/mysqld   <== 拷贝mysql启动脚本到mysql的命令路径;

[root@mobana mysql]# chmod +x /etc/init.d/mysqld      <== 使脚本有可执行权限;

[root@mobana mysql]# sed -i 's#/usr/local/mysql#/application/mysql#g' /application/mysql/bin/mysqld_safe /etc/init.d/mysqld 

             <== 二进制安装路径是/usr/local/mysql,需要替换成/application/mysql/bin/mysqld_dafe;

[root@mobana mysql]# /etc/init.d/mysqld start

Starting MySQL.. SUCCESS! 

[root@mobana mysql]# netstat -lntup|grep mysqld

tcp      0    0 0.0.0.0:3306           0.0.0.0:*       LISTEN    1656/mysqld         

[root@mobana mysql]# chkconfig --add mysqld

[root@mobana mysql]# chkconfig mysqld on         <== 设置开机启动mysql服务;

[root@mobana mysql]# chkconfig --list mysqld

mysqld          0:1:2:3:4:5:6:

[root@mobana mysql]#echo 'export PATH=/application/mysql/bin:$PATH' >>/etc/profile   <== 设置mysql全局使用路径;

[root@mobana mysql]# tail -l /etc/profile

export PATH=/application/mysql/bin:$PATH

[root@mobana mysql]# source /etc/profile     <== 执行source命令使上一行添加到/etc/profile中的内容直接生效;

[root@mobana mysql]# echo $PATH 

/application/mysql/bin:/application/mysql/bin:/oldboy/:/oldboy/:/oldboy/:/oldboy/:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

[root@mobana mysql]# mysql           <== 验证mysql是否可以全局使用;

mysql: Unknown OS character set 'GB18030'.

mysql: Switching to the default character set 'latin1'.

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 1

Server version: 5.5.32 MySQL Community Server (GPL)

Copyright (c) 2000, 2013, 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数据库文件时会出现以下错误信息:

[root@mobana mysql]# /application/mysql/scripts/mysql_install_db --basedir=/application/mysql --

datadir=/application/mysql/data/ --user=mysql

Neither host 'mobana' nor 'localhost' could be looked up with

/application/mysql/bin/resolveip

Please configure the 'hostname' command to return a correct

hostname.

If you want to solve this at a later stage, restart this script

with the --force option

解决方法:在/etc/hosts文件下添加127.0.0.1 localhost.localdomain localhost再次初始化

[root@mobana mysql]# /application/mysql/scripts/mysql_install_db --basedir=/application/mysql --

datadir=/application/mysql/data/ --user=mysql

WARNING: The host 'mobana' 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:


/application/mysql/bin/mysqladmin -u root password 'new-password'

/application/mysql/bin/mysqladmin -u root -h mobana password 'new-password'

Alternatively you can run:

/application/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 /application/mysql ; /application/mysql/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl

cd /application/mysql/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /application/mysql/scripts/mysqlbug script!


[root@mobana mysql]# tree /application/mysql/data/   <== 验证数据库;

|-- mysql
|   |-- columns_priv.frm
|   |-- columns_priv.MYD
|   |-- columns_priv.MYI
|   |-- db.frm
|   |-- db.MYD
|   |-- db.MYI
|   |-- event.frm
|   |-- event.MYD
|   |-- event.MYI
|   |-- func.frm
|   |-- func.MYD
|   |-- func.MYI
|   |-- general_log.CSM
|   |-- general_log.CSV
|   |-- general_log.frm
|   |-- help_category.frm
|   |-- help_category.MYD
|   |-- help_category.MYI
|   |-- help_keyword.frm
|   |-- help_keyword.MYD
|   |-- help_keyword.MYI
|   |-- help_relation.frm
|   |-- help_relation.MYD
|   |-- help_relation.MYI
|   |-- help_topic.frm
|   |-- help_topic.MYD
|   |-- help_topic.MYI
|   |-- host.frm
|   |-- host.MYD
|   |-- host.MYI
|   |-- ndb_binlog_index.frm
|   |-- ndb_binlog_index.MYD
|   |-- ndb_binlog_index.MYI
|   |-- plugin.frm
|   |-- plugin.MYD
|   |-- plugin.MYI
|   |-- proc.frm
|   |-- proc.MYD
|   |-- proc.MYI
|   |-- procs_priv.frm
|   |-- procs_priv.MYD
|   |-- procs_priv.MYI
|   |-- proxies_priv.frm
|   |-- proxies_priv.MYD
|   |-- proxies_priv.MYI
|   |-- servers.frm
|   |-- servers.MYD
|   |-- servers.MYI
|   |-- slow_log.CSM
|   |-- slow_log.CSV
|   |-- slow_log.frm
|   |-- tables_priv.frm
|   |-- tables_priv.MYD
|   |-- tables_priv.MYI
|   |-- time_zone.frm
|   |-- time_zone_leap_second.frm
|   |-- time_zone_leap_second.MYD
|   |-- time_zone_leap_second.MYI
|   |-- time_zone.MYD
|   |-- time_zone.MYI
|   |-- time_zone_name.frm
|   |-- time_zone_name.MYD
|   |-- time_zone_name.MYI
|   |-- time_zone_transition.frm
|   |-- time_zone_transition.MYD
|   |-- time_zone_transition.MYI
|   |-- time_zone_transition_type.frm
|   |-- time_zone_transition_type.MYD
|   |-- time_zone_transition_type.MYI
|   |-- user.frm
|   |-- user.MYD
|   `-- user.MYI
|-- performance_schema
|   |-- cond_instances.frm
|   |-- db.opt
|   |-- events_waits_current.frm
|   |-- events_waits_history.frm
|   |-- events_waits_history_long.frm
|   |-- events_waits_summary_by_instance.frm
|   |-- events_waits_summary_by_thread_by_event_name.frm
|   |-- events_waits_summary_global_by_event_name.frm
|   |-- file_instances.frm
|   |-- file_summary_by_event_name.frm
|   |-- file_summary_by_instance.frm
|   |-- mutex_instances.frm
|   |-- performance_timers.frm
|   |-- rwlock_instances.frm
|   |-- setup_consumers.frm
|   |-- setup_instruments.frm
|   |-- setup_timers.frm
|   `-- threads.frm
`-- test
    `-- db.opt

错误二:ERROR:1004 Can`tcreate file '/tmp/#sql300e_1_0.frm'(error:13)

原因是/tmp目录的权限问题导致;

[root@mobana mysql]# ll -d /tmp

drwxrwxrwt. 3 root root 4096 126 06:03 /tmp

[root@mobana mysql]# chmod 1777 /tmp




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值