linux图形界面如何安装MySQL,linux下如何安装mysql

林夕

12级

2011-05-15 回答

1.开启mysqld 服务,查看端口是否开启,mysql默认端口为3306.

2.Starting Mysql ,出现OK证明服务启动了。lsof -n -i:3306,看是否有mysqld服务,并且有mysql(LISTEN)的监听程序。

3.本地使用mysql 登录,或者指定用户,mysql服务器和密码:mysql -u root -h localhost.localdomain 并且输入密码,看是否进入mysql>的命令行。可以用show databases查看数据库,use mysql;show tables;查看表。

4.如果都能正常显示结果,证明mysql数据库安装成功。

卢韬旭

追问:

MySQL没有启动怎么让它启动呢?

追答:

chkconfig mysqld on

/etc/init.d/mysqld start

追问:

chkconfig mysql on

/etc/init.d/mysql start

这两个命令对的吧

追答:

对的,适用于使用rpm -ivh 安装的RPM包安装的MySQL.

chkconfig mysqld on 是开机启动,用户运行模式为2,3,4,5.

/etc/init.d/mysqld start 开始启动程序。

追问:

以下是我执行的一些命令,好像是不太正常是吧?

Using username "root".

Authenticating with public key "rsa-key-20110511"

Last login: Sun May 15 19:28:50 2011 from 10.128.120.235

[root@Web---Server ~]# ls

anaconda-ks.cfg  install.log    MySQL-server-5.5.12-1.rhel5.i386.rpm

Desktop    install.log.syslog

[root@Web---Server ~]# rpm -ivh MySQL-server-5.5.12-1.rhel5.i386.rpm

Preparing...    ########################################### [100%]

1:MySQL-server    ########################################### [100%]

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !

To do so, start the server, then issue the following commands:

/usr/bin/mysqladmin -u root password 'new-password'

/usr/bin/mysqladmin -u root -h Web---Server password 'new-password'

Alternatively you can run:

/usr/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.

Please report any problems with the /usr/bin/mysqlbug script!

[root@Web---Server ~]# chkconfig mysqld on

在 mysqld 服务中读取信息时出错:没有那个文件或目录

[root@Web---Server ~]# /etc/init.d/mysqld start

-bash: /etc/init.d/mysqld: 没有那个文件或目录

[root@Web---Server ~]# /etc/init.d/mysql start

Starting MySQL.....    [确定]

[root@Web---Server ~]# chkconfig mysql on

[root@Web---Server ~]# Starting Mysql

-bash: Starting: command not found

[root@Web---Server ~]# /etc/init.d/mysql start

Starting MySQL    [确定]

[root@Web---Server ~]# Starting Mysql

-bash: Starting: command not found

[root@Web---Server ~]# lsof -n -i:3306

COMMAND   PID  USER   FD   TYPE DEVICE SIZE NODE NAME

mysqld  27090 mysql   10u  IPv6 114433    TCP *:mysql (LISTEN)

[root@Web---Server ~]# mysql -u root -h localhost.localdomaih

-bash: mysql: command not found

[root@Web---Server ~]# mysql -u root -h localhost.localdomain

-bash: mysql: command not found

[root@Web---Server ~]# mysql -u root -h

-bash: mysql: command not found

[root@Web---Server ~]# use mysql;show tables;

-bash: use: command not found

-bash: show: command not found

[root@Web---Server ~]# mysql -u root

-bash: mysql: command not found

[root@Web---Server ~]# ls

anaconda-ks.cfg  install.log    MySQL-server-5.5.12-1.rhel5.i386.rpm

Desktop    install.log.syslog

[root@Web---Server ~]# /etc/init.d/mysqld start 开始启动程序

-bash: /etc/init.d/mysqld: 没有那个文件或目录

[root@Web---Server ~]# cd /etc/init.d

[root@Web---Server init.d]# sl

-bash: sl: command not found

[root@Web---Server init.d]# ls

acpid    dund    krb524    nfslock    saslauthd

anacron    firstboot   kudzu    nscd    sendmail

apmd    functions   lvm2-monitor    ntpd    single

atd    gpm    mcstrans    oddjobd    smartd

auditd    haldaemon   mdmonitor    pand    sshd

autofs    halt    mdmpd    pcscd    syslog

avahi-daemon    hidd    messagebus    portmap    tcsd

avahi-dnsconfd    hsqldb    microcode_ctl   psacct    vncserver

bluetooth    httpd    multipathd    rawdevices    wdaemon

capi    ibmasm    mysql    rdisc    wpa_supplicant

conman    ip6tables   netconsole    readahead_early  xfs

cpuspeed    iptables    netfs    readahead_later  ypbind

crond    irda    netplugd    restorecond    yum-updatesd

cups    irqbalance  network    rpcgssd

cups-config-daemon  isdn    NetworkManager  rpcidmapd

dnsmasq    killall    nfs    rpcsvcgssd

[root@Web---Server init.d]# cd mysql

-bash: cd: mysql: 不是目录

[root@Web---Server init.d]#

追答:

/etc/init.d/mysqld start 出现Starting MySQL,确定,证明mysql 安装成功,并且启动正常。

lsof -n -i:3306发现有mysqld 的监听程序证明mysqld服务进程已经启动,并且监听客户端请求。

输入mysql,或者mysql -u root -h localhost.localdomain就可以登录mysql.

出现mysql>后,输入show databases;发现出现三个默认的数据库。

use mysql;回车;show tables; 就会发现mysql数据库里的表。

/etc/init.d里面的mysqld是可执行文件,不是目录。可以在/etc/init.d/目录下使用./mysqld restart重启mysqld服务。

你的设置开机启动mysqld服务没有结果,说明chkconfig命令没发挥作用。使用chkconfig mysqld on设置后,使用chkconfig --list |grep "mysqld"查看情况。

如果没有安装chkconfig 包,可以mount /dev/cdrom  /media;cd /media/Server;rpm -ivh chkconfig-1.3.30.1-1.i386.rpm安装,然后使用chkconfig命令设置,chkconfig mysqld on设置mysqld自动开机启动。

安装mysql

1.rpm -ivh perl-CGI-(tab)

2.rpm -ivh perl-DBI-1.52-1.fc6.i386.rpm

3.rpm -ivh mysql-5.0.22-2.1.i386.rpm \ perl-DBD-MySQL-3.0007-1.fc6.i386.rpm

4.rpm -ivh mysql-server-5.0.22-2.1.i386

卢韬旭

追问:

我敲了这个命令lsof -n -i:3306返回以下结果是什么意思?

[root@Web---Server ~]# lsof -n -i:3306

COMMAND   PID  USER   FD   TYPE DEVICE SIZE NODE NAME

mysqld  27098 mysql   10u  IPv6 114454    TCP *:mysql (LISTEN)

追答:

mysql的服务进程默认端口号是3306. -n是忽略主机名,-i选择IPV4协议文件。

pid就应当是mysql的主进程号。

USER是用户名mysql.

TCP *:mysql(LISTEN)就是通过TCP协议,监听对mysql服务器的请求。

说明mysql服务开启了监听程序来监听客户的请求,准备处理客户对mysql服务器的请求。

卢韬旭

追问:

[root@Web---Server ~]# lsof -n -i:3306

COMMAND   PID  USER   FD   TYPE DEVICE SIZE NODE NAME

mysqld  27098 mysql   10u  IPv6 114454    TCP *:mysql (LISTEN)

以上这些可以说明MySQL 安装成功了么?

追答:

可以说明MySQL安装成功了,可以进行应用了。尤其运行在本地。

当然要是复杂的,比如主从,优化,还需要以后继续深入了解。

以上是说明MySQL监听服务正在运行,MySQL正在等待接收客户端请求。

卢韬旭

追问:

[root@Web---Server ~]# ls

anaconda-ks.cfg    mysql-5.1.56.tar.gz

Desktop    MySQL-server-5.5.12-1.rhel5.i386.rpm

install.log    MySQL-server-community-5.1.57-1.rhel5.i386.rpm

install.log.syslog

[root@Web---Server ~]# rpm -ivh MySQL-server-community-5.1.57-1.rhel5.i386.rpm

Preparing...    ########################################### [100%]

1:MySQL-server-community ########################################### [100%]

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !

To do so, start the server, then issue the following commands:

/usr/bin/mysqladmin -u root password 'new-password'

/usr/bin/mysqladmin -u root -h Web---Server password 'new-password'

Alternatively you can run:

/usr/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.

Please report any problems with the /usr/bin/mysqlbug script!

Starting MySQL...[确定]

Giving mysqld 2 seconds to start

[root@Web---Server ~]#

上面这些已经成功安装了MySQL而且也成功启动了服务,接下来就是要为 root用户创建密码。

可是在我敲以下命令的时候提示

[root@Web---Server ~]# /usr/bin/mysqladmin -u root password acb123456

-bash: /usr/bin/mysqladmin: 没有那个文件或目录

为什么会提示没有那个文件或目录?是不是没有安装登录工具?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值