LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 07-25-2009, 02:06 PM   #1
pellicle
Member
 
Registered: Jul 2008
Location: Finland
Distribution: RHEL4
Posts: 139

Rep: Reputation: 15
MySQL - can't do much after login


Hi

found a few similar threads but still can't get my mySQL to work

I've got an older Redhat 4 installation which I installed mySQL from the cd's at system install time

Code:
# cat /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1

[mysql.server]
user=mysql
basedir=/var/lib

[mysqld_safe]
err-log=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
I can use this to get a connection like:

Code:
# mysql -umysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 42 to server version: 4.1.12

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

mysql>
but I can't seem to do much in there ... this works

Code:
mysql> show databases;
+----------+
| Database |
+----------+
| test     |
+----------+
1 row in set (0.00 sec)
... but

I can't seem to create anything (user or database) ... I can't even grant myself anything.

any thoughts?
 
Old 07-25-2009, 03:35 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,635

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by pellicle View Post
Hi

found a few similar threads but still can't get my mySQL to work

I've got an older Redhat 4 installation which I installed mySQL from the cd's at system install time

... but

I can't seem to create anything (user or database) ... I can't even grant myself anything.

any thoughts?
Yep...you don't have rights to do anything, and don't have any databases defined. From the MySQL box, try SU'ing to root, and (as root), try just typing in "mysql".

The root user (from a fresh installation), is granted all rights locally. You should be able to create more users, databases, etc., from that point, and not have to go in as root again, except for rare cases.
 
Old 07-26-2009, 12:25 AM   #3
pellicle
Member
 
Registered: Jul 2008
Location: Finland
Distribution: RHEL4
Posts: 139

Original Poster
Rep: Reputation: 15
Hi

sorry ... should have said, this was as root ... should I be su - ing to mysql?
 
Old 07-26-2009, 02:08 AM   #4
kirukan
Senior Member
 
Registered: Jun 2008
Location: Eelam
Distribution: Redhat, Solaris, Suse
Posts: 1,278

Rep: Reputation: 148Reputation: 148
You have logged in as mysql user (i mean your mysql login) this user haven't all rights therefore login your mysql using root user(supper user).

Read again TB0ne post

Quote:
Yep...you don't have rights to do anything, and don't have any databases defined. From the MySQL box, try SU'ing to root, and (as root), try just typing in "mysql".

The root user (from a fresh installation), is granted all rights locally. You should be able to create more users, databases, etc., from that point, and not have to go in as root again, except for rare cases.

Last edited by kirukan; 07-26-2009 at 02:11 AM.
 
Old 07-26-2009, 02:18 AM   #5
pellicle
Member
 
Registered: Jul 2008
Location: Finland
Distribution: RHEL4
Posts: 139

Original Poster
Rep: Reputation: 15
Hi

I can seemingly start, but I can only connect to the test database;

Code:
mysql> status;
--------------
mysql  Ver 14.7 Distrib 4.1.12, for redhat-linux-gnu (i386) using readline 4.3

Connection id:          9
Current database:       test
Current user:           mysql@localhost
SSL:                    Not in use
Current pager:          stdout
Using outfile:          ''
Using delimiter:        ;
Server version:         4.1.12
Protocol version:       10
Connection:             Localhost via UNIX socket
Server characterset:    latin1
Db     characterset:    latin1
Client characterset:    latin1
Conn.  characterset:    latin1
UNIX socket:            /var/lib/mysql/mysql.sock
Uptime:                 3 min 49 sec

Threads: 1  Questions: 19  Slow queries: 0  Opens: 12  Flush tables: 1  Open tables: 1  Queries per second avg: 0.083
--------------

mysql> create database pergamentit;
ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'pergamentit'
mysql>
I tried making an edit in my conf file to add root ... just a wild stab

Code:
[root@home ~]# cat /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1

[mysql.server]
user=mysql
user=root
basedir=/var/lib

[mysqld_safe]
err-log=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[root@home ~]#
 
Old 07-26-2009, 02:26 AM   #6
micxz
Senior Member
 
Registered: Sep 2002
Location: CA
Distribution: openSuSE, Cent OS, Slackware
Posts: 1,131

Rep: Reputation: 75
Quote:
Originally Posted by pellicle View Post
Current user: mysql@localhost
Still not root here as mentioned above'
 
Old 07-26-2009, 05:52 AM   #7
pellicle
Member
 
Registered: Jul 2008
Location: Finland
Distribution: RHEL4
Posts: 139

Original Poster
Rep: Reputation: 15
but I'm ssh'ed into the server as root ... when I run the command

Quote:
# mysql --user=root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
yet ...

Quote:
# mysql --user=mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4 to server version: 4.1.12

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

mysql>
I have even edited the file
Quote:
[root@oracle ~]# cat /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1

[mysql.server]
user=root
#user=mysql
basedir=/var/lib

[mysqld_safe]
err-log=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
and restarted

so what more do you mean by run as root, and how can I run as root if you can assist please

Last edited by pellicle; 07-26-2009 at 06:02 AM.
 
Old 07-26-2009, 06:01 AM   #8
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
Hello,

Your MySQL installation doesn't accept the root user without password. This password you need is the one provided upon installation when asked.
Code:
mysql -u root -p
should ask you for a password. Once provided you are logged in as 'root' with all rights. If you still don't have any rights you will be able to grant yourself all rights on all databases, either on localhost or via client, or both.

Kind regards,

Eric
 
Old 07-26-2009, 06:03 AM   #9
pellicle
Member
 
Registered: Jul 2008
Location: Finland
Distribution: RHEL4
Posts: 139

Original Poster
Rep: Reputation: 15
Hi

Quote:
Originally Posted by EricTRA View Post
Your MySQL installation doesn't accept the root user without password. This password you need is the one provided upon installation when asked.
Code:
mysql -u root -p
should ask you for a password.
well and good ... but I know the root password (its my personal box) and it seems not to accept it ... as I already of course tried that
 
Old 07-26-2009, 06:06 AM   #10
pellicle
Member
 
Registered: Jul 2008
Location: Finland
Distribution: RHEL4
Posts: 139

Original Poster
Rep: Reputation: 15
For instance

I ssh to the box as root

enter my root password

then when I try mysql I get this :

Quote:
# mysql --user=root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
 
Old 07-26-2009, 06:06 AM   #11
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
Hi,

The root password for MySQL root user is NOT always the same as the root user for your linux box. When installed MySQL asked you for a root password. If you provided the same as for your linux box then it should work. You can always reset the MySQL root password. Root on linux and Root on MySQL are two different logins.

Kind regards,

Eric
 
Old 07-26-2009, 09:32 AM   #12
pellicle
Member
 
Registered: Jul 2008
Location: Finland
Distribution: RHEL4
Posts: 139

Original Poster
Rep: Reputation: 15
Hi

Quote:
Originally Posted by EricTRA View Post
You can always reset the MySQL root password. Root on linux and Root on MySQL are two different logins.
I seem not to be able to ...
 
Old 07-26-2009, 09:41 AM   #13
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
Hi,

Using one of the procedures described HERE should do the trick. After resetting the root password you should be able to log in.

Kind regards,

Eric
 
Old 07-26-2009, 09:59 AM   #14
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
FYI. You don't need to su to root first when logging in to mysql as root. Using the "-u root" is enough. You are accessing the 'root' user on the database, using the MySQL password, not the Linux root password.

There should be a mysql manual that came with your installation (probably on a pdf). Be sure to read
the section on securing mysql after installing.

use mysql;
select Host, User, password from user;
Make sure the password field isn't blank for the root user account when you are done following the last post.

Last edited by jschiwal; 07-26-2009 at 10:13 AM.
 
Old 07-26-2009, 02:05 PM   #15
pellicle
Member
 
Registered: Jul 2008
Location: Finland
Distribution: RHEL4
Posts: 139

Original Poster
Rep: Reputation: 15
Hi

well it seemed like good advice, and perhaps somewhere else it may work.

I followed the steps in 1.4.1.2. Resetting the Root Password on Unix Systems

obviously substituting parameters such as

Quote:
shell> kill `cat /mysql-data-directory/host_name.pid`
made the script file

Quote:
UPDATE mysql.user SET Password=PASSWORD('blahblah') WHERE User='root';
FLUSH PRIVILEGES;
and followed the rest of the steps

nope

I must say its confusing having users like "root" on a system that root has a specific meaning to.

its been a long day with zero productivity and I got Oracle going in less than 1/4 the time.

perhaps my installation has something squiff about it ... but I am past caring now its too late.

another day

thanks for the contributions however
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot login to mysql swmok Linux - Software 3 06-20-2007 11:02 PM
cannot login in MYSQL rajeshdogra Linux - Software 9 01-01-2006 09:15 AM
Can not login into mysql. saudoi Solaris / OpenSolaris 1 11-30-2005 02:20 AM
mysql login Ab3n Linux - Newbie 2 07-04-2005 10:45 AM
mysql login sopiaz57 Linux - Security 1 01-05-2004 10:48 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 04:11 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration