Linux系统自带的Mysql 数据库启动问题

针对Linux系统自带Mysql 数据库不能使用的情况,可能是在安装过程有没有安装mysql server 安装时即使选了安装MYSQL(图形界面安装),只有打开旁边“细节”,从里面勾选选上server才可以。

安装完成后在/usr/bin 目录下会生成许多MySQL的相关文件,其中有一个名为mysqld_safe 启动服务的脚本文件,执行这个脚本文件后,发现错误'/var/lib/mysql/mysql.sock' 查看mysql服务才发现,没有起来,于是执行/etc/init.d/mysqld start启动服务后,/usr/bin 执行mysql 成功进入数据库!

[pan@localhost ~]$ su – root

Password:

[root@localhost ~]# cd /usr/bin

[root@localhost bin]# ./mysqld_safe --user=root &

[1] 12969

[root@localhost bin]# Starting mysqld daemon with databases from /var/lib/mysql

STOPPING server from pid file /var/run/mysqld/mysqld.pid

090606 15:20:04 mysqld ended

mysql

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

[1]+ Done                    ./mysqld_safe --user=root

[root@localhost bin]# mysql

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

[root@localhost bin]# /etc/rc.d/init.d/mysqld status

mysqld is stopped

[root@localhost bin]# /etc/init.d/mysqld start (或者service mysqld restart,而service mysqld stop 停止mysql的服务)

Initializing MySQL database:                               [ OK ]

Starting MySQL:                                            [ OK ]

[root@localhost bin]# mysql

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

Your MySQL connection id is 2 to server version: 4.1.22

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

现在进行环境变量的配置,可以针对用户配置用户的环境变量,以root用户例,

[root@localhost bin]# cd

[root@localhost ~]# ls –a .bash_profile 是个隐藏文件,所以要-a

. Desktop          .gstreamer-0.8      .mozilla

..               .dmrc            .gtkrc              .mysql_history

anaconda-ks.cfg .eggcups         .gtkrc-1.2-gnome2   .nautilus

.bash_history    .fullcircle      .ICEauthority       .recently-used

.bash_logout     .gconf           .icons              .rhn-applet.conf

.bash_profile    .gconfd          install.log         .tcshrc

.bashrc          .gnome           install.log.syslog .viminfo

.config          .gnome2          .kde                .xauthC1s54N

.cshrc           .gnome2_private .metacity           .xautheKBniS

[root@localhost ~]# vi .bash_profile (进行修改)

# .bash_profile

# Get the aliases and functions

if [ -f ~/.bashrc ]; then

        . ~/.bashrc

fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin:/usr/bin (此处添加注意冒号)

export PATH

unset USERNAME

[root@localhost ~]# source .bash_profile (更新一下配置文件)

也可以针对系统环境配置,如下:

[root@localhost ~]# vi /etc/profile

# /etc/profile

# System wide environment and startup programs, for login setup

# Functions and aliases go in /etc/bashrc

pathmunge () {

        if ! echo $PATH | /bin/egrep -q "(^|:)$1($|:)" ; then

           if [ "$2" = "after" ] ; then

             PATH=$PATH:$1

           else

              PATH=$1:$PATH

           fi

        fi

}

# Path manipulation

if [ `id -u` = 0 ]; then

        pathmunge /sbin

        pathmunge /usr/sbin

        pathmunge /usr/local/sbin

        pathmunge /usr/bin

fi

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值