mysql

Tuesday, February 28, 2006

Access denied for user 'root'@'localhost' (using password: NO) - The cure

Sometimes you cant log into the mysql in root mode:

bash-2.03# /usr/local/mysql/bin/mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

The cure (what to do in that case)

In that case try to log in with host name :

/usr/local/mysql/bin/mysql -h 172.16.80.63 -uroot and you might have permissions to do all you want.
or even try : [root@mas2qa root]# /usr/local/mysql/bin/mysql -ulocalhost.localadmin

Wednesday, February 22, 2006

Installing msyql 64 bit on solaris

Here is the command history of installing a mysql 64 bit on a solaris machine (copying the package, untar, install, update with READ-COMMITED)

346 scp root@xx.xx.xx.xx:/usr/local/mysql* ./
347 scp root@xx.xx.xx.xx:/var/spool/pkg/mysql* ./
348 ls -al
349 rm mysql-standard-4.1.12-sun-solaris2.8-sparc-64bit.pkg
350 ls -al
351 tar xvf mysql-max-5.0.18-solaris8-sparc-64bit.tar
352 ln -s mysql-max-5.0.18-solaris8-sparc-64bit mysql
353 ls -al
354 mv mysql-max-5.0.18-solaris8-sparc-64bit.tar /var/spool/pkg/
355 cd mysql
356 vi INSTALL-BINARY
357 groupadd mysql
358 useradd -g mysql mysql
359 scripts/mysql_install_db --user=mysql
360 chown -R root .
361 chown -R mysql data
362 chgrp -R mysql .
363 cp support-files/mysql.server /etc/init.d
364 chmod 755 /etc/init.d/mysql.server
365 vi /etc/init.d/mysql.server
366 ls -al
367 cp support-files/my-medium.cnf ./my.cnf
368 ls -al
369 vi my.cnf (add this: transaction-isolation=read-committed)
370 /etc/init.d/mysql.server start
371 vi my.cnf - put READ-COMMITED
372 /etc/init.d/mysql.server stop
373 /etc/init.d/mysql.server start

INSTALL-BINARY says this:
shell> groupadd mysql
shell> useradd -g mysql mysql
shell> cd /usr/local
shell> gunzip < /PATH/TO/MYSQL-VERSION-OS.tar.gz | tar xvf -
shell> ln -s FULL-PATH-TO-MYSQL-VERSION-OS mysql
shell> cd mysql
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql data
shell> chgrp -R mysql .
shell> bin/mysqld_safe --user=mysql &

How to select top 10 rows from a table

mysql> SELECT * FROM table_name LIMIT 10;
SELECT * FROM tbl LIMIT 5,10 gives 10 rows starting from row #5