Showing posts with label Database. Show all posts
Showing posts with label Database. Show all posts

Wednesday, March 14, 2012

How to get next AUTO_INCREMENT value in mysql

there are two possibilities to access next auto_increment variable associated with a particular table in MySql

1) Using information schema

select auto_increment
from information_schema.tables
where table_schema = 'db_name'
 and table_name = 'table_name'

2) accessing status of database

SHOW TABLE STATUS  where name="table_name"

1st give only next auto increment value but second gives some additional information other than that.

hope this helps....cheers......

Monday, July 13, 2009

mysql password reset in 10 steps

suppose u forgot the password of u'r mysql server
while u are trying to logged in it will display a message like
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
so here is a solution to change the password of mysql with out loss of u'r data
first you have to stop the mysqld service
1)service mysqld stop

then u have to find out the mysqld path
2) whereis mysqld
it will display the mysqld location in your system
Then u have to run the mysqld with the option --skip-grant-tables

3)/usr/libexec/mysqld --skip-grant-tables

then the mysql will be started
090713 13:15:33 InnoDB: Started; log sequence number 0 11427172
090713 13:15:33 [Note] /usr/libexec/mysqld: ready for connections.
Version: '5.0.45' socket: '/var/lib/mysql/mysql.sock' port: 3306 Source distribution

Now u can login to mysql with out using password using a client
4)mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.0.45 Source distribution

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

mysql>

after that u have to choose the mysql as your database
5)use mysql
in mysql database the user table contains the login details of the user

to see the structure of the table "user" just input
6)desc user

u have to use update command to change the password of a user
7)update user set password=password('test123') where user='root';
this will set the password of root to test123

8)flush privilges
;

kill the mysqld u have started
9)killall -9 mysqld
start mysqld service again

10)service mysqld start

now u can login to the mysql root account using test123 as password

LinkWithin

Related Posts with Thumbnails