您的位置:首页 > 数据库 > MySQL

mysql简单安装使用

2014-12-14 22:27 281 查看
centos5.5 64bit上安装使用

1、yum install mysql

2、service mysqld start

如果不执行的话会出现问题

[root@rac1 ~]# mysql

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

执行过程

[root@rac1 ~]# service mysqld start

初始化 MySQL 数据库: 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:

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

/usr/bin/mysqladmin -u root -h rac1 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.

You can start the MySQL daemon with:

cd /usr ; /usr/bin/mysqld_safe &

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

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

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

The latest information about MySQL is available on the web at
http://www.mysql.com

Support MySQL by buying support/licenses at http://shop.mysql.com
[确定]

启动 mysqld: [确定]

3、更改数据库root密码

[root@rac1 ~]# mysql -u root -p

Enter password:

ERROR 1045 (28000): Access denied for user
'root'@'localhost' (using password: YES)

[root@rac1 ~]# /usr/bin/mysqladmin -u root password 'loge'

4、然后登陆使用

[root@rac1 ~]# mysql -u root -p

Enter password:

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

Your MySQL connection id is 6

Server version: 5.0.95 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.

5、客户端连接出现问题ERROR 1130

mysql> show databases;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| test               |

+--------------------+

3 rows in set (0.00 sec)

mysql> use mysql

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

Database changed

mysql> select host,user from user;

+-----------+------+

| host      | user |

+-----------+------+

| 127.0.0.1 | root |

| localhost |      |

| localhost | root |

| rac1      |      |

| rac1      | root |

+-----------+------+

5 rows in set (0.00 sec)

mysql> update user set host='%' where user='localhost';

Query OK, 0 rows affected (0.01 sec)

Rows matched: 0  Changed: 0  Warnings: 0

mysql> update user set host='%' where host='localhost';

Query OK, 2 rows affected (0.00 sec)

Rows matched: 2  Changed: 2  Warnings: 0

mysql> flush priveges;

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'priveges' at line 1

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

记得修改完刷新一下权限

ok!

另外mariadb操作一样



 

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: