[root@server01 ~]#rpm -qa | grep -i mysql
[root@server01 ~]#ls /home/oracle
app jdk-7u9-linux-i586.rpm MySQL-server-5.5.28-1.rhel5.i386.rpm
CollabNetSubversionEdge-3.0.0_linux-x86.tar.gz MySQL-client-5.5.28-1.rhel5.i386.rpm oraInventory
[root@server01 ~]#rpm -ivh MySQL-server-5.5.28-1.rhel5.i386.rpm
error: open of MySQL-server-5.5.28-1.rhel5.i386.rpm failed: 沒有那個文件或目錄
[root@server01 ~]#rpm -ivh /home/oracle/MySQL-server-5.5.28-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 tffserver01 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@server01 ~]#rpm -ivh /home/oracle/MySQL-client-5.5.28-1.rhel5.i386.rpm
Preparing... ########################################### [100%]
1:MySQL-client ########################################### [100%]
[root@server01 ~]#mysql -uroot
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[root@server01 ~]#service mysql start
Starting MySQL....... [確定]
[root@server01 ~]#mysql -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.28 MySQL Community Server (GPL)
Copyright (c) 2000, 2012, 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> show user;
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 'user' at line 1
mysql> exit
Bye
[root@server01 ~]#usr/bin/mysqladmin -u root password 'mysql'
-bash: usr/bin/mysqladmin: 沒有那個文件或目錄
[root@server01 ~]#/usr/bin/mysqladmin -u root password 'mysql'
[root@server01 ~]#mysql -uroot
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
[root@server01 ~]#mysql -uroot -pmysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.5.28 MySQL Community Server (GPL)
Copyright (c) 2000, 2012, 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> exit
Bye
[root@server01 ~]#mysql -uroot -pmysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.5.28 MySQL Community Server (GPL)
Copyright (c) 2000, 2012, 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> grant all privileges on *.* to 'root'@'192.168.1.11' identified by 'mysql' with grant option;
Query OK, 0 rows affected (0.07 sec)
mysql> exit
Bye
---------------------------------------------------------------------------------------------------------
[root@server01 Server]#rpm -ivh perl-DBI-1.52-2.el5.i386.rpm
warning: perl-DBI-1.52-2.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:perl-DBI ########################################### [100%]
[root@server01 Server]#rpm -ivh mysql-5.0.77-4.el5_5.4.i386.rpm
warning: mysql-5.0.77-4.el5_5.4.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:mysql ########################################### [100%]
[root@server01 Server]#rpm -ivh mysql-devel-5.0.77-4.el5_5.4.i386.rpm
warning: mysql-devel-5.0.77-4.el5_5.4.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:mysql-devel ########################################### [100%]
[root@server01 Server]#rpm -ivh /home/oracle/MySQL-embedded-5.5.28-1.rhel5.i386.rpm
error: Failed dependencies:
MySQL-devel is needed by MySQL-embedded-5.5.28-1.rhel5.i386
安裝MySQL-embedded-5.5.28-1.rhel5.i386時需要解決依賴問題...
***********************************************************************************
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)問題解決:轉載自Linux中文站. http://www.linux265.com/blog/index.php/archives/474
登錄mysql時報以上錯誤,解決方法如下:重置密碼 mysqladmin -uroot -p password 'newpassword'
# /etc/init.d/mysql stop
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking & # mysql -u root mysql mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root'; mysql> FLUSH PRIVILEGES; mysql> quit
# /etc/init.d/mysql restart # mysql -uroot -p Enter password: < 輸入新設的密碼newpassword> mysql>
如果可以用navicat工具連過去,查看用戶權限,修改用戶權限都是很方便的,但很多時候MySQL都是只允許localhost訪問,這時就只能用命令了
以前用
mysql> select * from mysql.user where user='username';
今天發現這個更方便:
mysql> show grants for username@localhost; 或mysql> show grants for root@'localhost'; 或mysql> show grants for root@'%'; 或mysql> show grants;
show可以看到很多東西
show create database dbname; 這個可以看到創建數據庫時用到的一些參數。
show create table tickets; 可以看到創建表時用到的一些參數