I can believe fly.

Showing posts with label mysql. Show all posts
Showing posts with label mysql. Show all posts

Wednesday, October 13, 2010

mysql连接,访问拒绝

错误信息:Access denied for user 'kscm'@WIN-WP4X5EPPTIO'(useing password:YES)

情景A:
  1. 明明本机上的客户端可以正常连接数据库,但程序部署起来还是报错.
  2. 明明本机的电脑名称WIN-WP4X5EPPTIO已改名了,也重启了电脑,但是连接时还是显示旧的信息..

解答A:
  1. 程序部署连接数据库的账号信息有误
  2. 在my.ini文件中找到[mysqld],在此段的配置信息中添加skip-name-resolve,这样客户端请求连接时就会用IP地址了.


情景B:

用新创建的用户执行一些SQL脚本(仓库新数据库及表),但执行失效,反应过来估计权限不够,应该用root账号.

然后重新想用root账号连接,却怎么也连不上去了.前几分钟还连过一次,现怎么不行了.
解答B:
原以为是像上次出现密码有问题??因此按照以下步骤进行了密码更新:
  1. 首先,在my.ini文件中的[mysqld]段配置信息内加上skip-grant-tables
  2. 重启mysql服务
  3. 来到mysql安装目录下的bin,打开cmd,执行mysql -u root,这时候要你输入密码,回车即可
  4. 在mysql>环境下执行以下几条命令:

mysql>use mysql;

mysql>UPDATE user SET password=PASSWORD("5688") WHERE user='root';

mysql>FLUSH PRIVILEGES;


结果,重新登录仍然无效.
同事说,其实密码是已经改了,大部分跟授权有关.
因此,他按照以下步骤进行了处理:
  1. 首先,在my.ini文件中的[mysqld]段配置信息内加上skip-grant-tables
  2. 重启mysql服务
  3. 来到mysql安装目录下的bin,打开cmd,执行mysql -u root,这时候要你输入密码,回车即可
  4. 在mysql>环境下执行以下命令,目的是让111.111.111.158机子可以用root账号登录

mysql>use mysql;
mysql>update user set host = '111.111.111.158' where user = 'root';
  1. 利用111.111.111.158机子的客户端,竟然可以正常连接.且继续执行以下命令,目的是让本机可以连接

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY PASSWORD '*00A51F3F48415C7D4E8908980D443C29C69B60C9';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'111.111.111.160' IDENTIFIED BY PASSWORD '*00A51F3F48415C7D4E8908980D443C29C69B60C9';
  1. 结果无效,不死心的参考资料继续执行:

mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY PASSWORD'*00A51F3F48415C7D4E8908980D443C29C69B60C9';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'dubabuild' IDENTIFIED BY PASSWORD '*00A51F3F48415C7D4E8908980D443C29C69B60C9';
  1. 回到本机,执行以下命令行,都一样报"Access denied"的错误信息

mysql -u root -h 10.20.239.160
mysql -u root -h 127.0.0.1
mysql -u root -h localhost
  1. 继续在网络上查找解决的方法,看到一则信息后改变了连接方式即执行mysql -u root -p,

这里候要求你输入密码,直接输入新密码,登录成功.
  1. 回到mysql administrator工具,利用root账号采用新的密码,一样登录成功了.
  2. 然后,利用mysql admini工具,保留%/localhost的授权连接,退出再重新登录正常了.


总结:如果出现类似这样的问题,一检查账号密码是否有误,二检查援权问题.

重装mysql,服务启动不了

问题现象:
---------------------------
Services
---------------------------
Windows could not start the MySQL service on Local Computer.
Error 1067: The process terminated unexpectedly.
---------------------------
OK
---------------------------
问题解答:
在my.ini中找到datadir="E:/mysql_data/Data/",然后将在此目录下的数据删除

Tuesday, October 12, 2010

mysql编码设置

问题现象:

mysql administrator工具连接数据库,打开tools->mysql command line client执行sql脚本,发现带有中文的sql脚本在执行后,数据表里查看时,全变为乱码了.

问题解答:

检查了sql脚本的存储格式,全都是存为utf-8了.那就是mysql administrator工具编码的问题了.找了tools->options的信息,也没见设置编码的配置.

突然想,执行脚本用的是mysql命令,那应该跟mysql工具的环境有关系才对.因此找到设置编码的方式了:mysql安装后,默认的编码是Latin1,这是不支持中文的.打开my.ini文件,分别将mysql和mysqld下的default-character-set值改为utf8,然后
重启mysql,这就可以正常显示中文了(呃,乱码的数据表需要重新执行脚本,不然好像还是乱码).

[转]mysql安装


Install and Configure MySQL 5.1.30 on Windows Server 2008

Feb
26
« »

In this article I will perform an installation of MySQL 5.1.30 on Windows Server 2008, I will take you step-by-step through the whole installation. MySQL is the world's most popular open source database engine, it's fast, stable and reliable for most situations.

Configuration Information

Platform: Hyper V Host OS: Windows Server 2008 Installation Media: MySQL 5.1.30 was downloaded from http://dev.mysql.com/downloads/ CPU: 2 dedicated 2.0Ghz RAM: 1024mb Disk: 40GB

Installation

Run Setup.exe – This version of

Click "Next" on the Setup Wizard window

I am going to select "Custom" installation so I can see all available options, Press "Next" to continue

I want to change the location of my installation to C:MySQL, press "Change"

I changed "C:Program FilesMySQLMySQL Server 5.1″ to "C:MySQL", I am only changing this location for personal preference, and you can make it whatever directory you wish. Press "OK" to continue

I also want to change the location of the data the MySQL will store. Select "MySQL Server Datafiles. Press "Change" to continue

I changed "C:Program FilesMySQLMySQL Server 5.1″ to "C:MySQL", I am only changing this location for personal preference, and you can make it whatever directory you wish. Press "OK" to continue

Press "Next" to continue

Setup is ready to begin the installation. I verified that the destination folder and data folder is set to C:MySQL. Press "Install" to continue

Installation will begin to copy the files

After installation MySQL includes shameless plugs for their enterprise subscription. Press "Next" to continue

Here is one more shameless plug from MySQL. Press "Next" to continue

Select "Configure the MySQL Server now". Press Finish to continue

Configuration

Press "Next" at the Welcome screen to continue

Because I am a techie I am going to select "Detailed Conifugration". Press "Next" to continue

I am going to use this to run blog applications so I am going to select "Server Machine", you can select what is best for your suited for your goal. Press "Next" to continue

I am going to choose "Multifunction Database" because it allows me the flexibility of Transactional and Non-Transactional Database's to coexist, again you can select what is best for your suited for your goal. Press "Next" to continue

Choose "Installation Path" so it will store the InnoDB Tablespace Settings under the Installation directory. I like to keep everything in the same place, the default location puts this elsewhere. Press "Next" to continue

Because this is for a blog I am going to select "Online Transaction Processing (OLTP)", you can select what is best for your suited for your goal. Press "Next" to continue

I left the defaults for TCP/IP and I unchecked "Enable Strict Mode", some blog applications associated with WordPress have an issue if this is enabled. Press "Next" to continue

Keep the default "Standard Character Set". Press "Next" to continue

I checked off "Install As Windows Service", set the "Service Name" to "MySQL" and checked off "Launch the MySQL Server automatically". I checked off "Include Bin Directory in Windows PATH" so I can run the client tools from any location in the command prompt and not have to go to the C:MySQLBin directory. Press "Next" to continue

Enter a new password for the root account, retype the password. Press "Next" to continue

Press "Execute" to initiate the configuration changes to MySQL

The configuration wizard will make the requested changes

Make sure all changes were successful. Press "Finish" to continue

Verification

Go to C:MySQL. Bin is where the system files for MySQL are located. Data is the directory where the databases will be stored, and my.ini is where most of the configuration is kept.

From the command prompt run the following command, if you get the error "'mysql' is not recognized as an internal or external command" then you will need to navigate to the "Bin" directory under your MySQL Installation and run it from there. This is used to test connectivity to the MySQL Server.

mysql –u root –p