LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-03-2012, 03:42 PM   #1
southpointingchariot
Member
 
Registered: Sep 2012
Posts: 31

Rep: Reputation: Disabled
I've screwed up my Lamp server


Sorry for the long post - I'm not exactly sure what my real problem is. I'm new to linux, and fairly new to the administration game. I'm used to using out of the box systems like WAMP on Windows - so forgive the stupidity you're about to hear.

I installed LAMP using tasksel (using this tutorial: http://www.unixmen.com/install-lamp-...erick-meerkat/) a while ago. I recently decided I wanted to learn how to build a CMS, and a tutorial I found suggested using Xampp to do so.

I installed Xampp. When starting XAMPP, I got the message "XAMPP: Another MySQL daemon is already running.", and MySQL was deactivated in the XAMPP status. After trying the usual methods to fix it, I followed a suggestion given to me on a forum and uninstalled a bunch of packages relating to LAMP. I still could not get Xampp to work, and after further searching was told it would not really suit my needs.

I uninstalled Xampp using "sudo rm -rf /opt/lamp", and tried to install Lamp using Tasksel again. However, I now I get the error "ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)" during installation.

Clearly I've done some damage. I'm happy to use Lamp if that's the wisest option, though I was attracted by Xampp cosmetic user-friendliness. Thoughts on what I should do next?

Last edited by southpointingchariot; 09-03-2012 at 03:58 PM.
 
Old 09-03-2012, 04:19 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Hi, welcome to LQ!

Looking at your browser-icon you appear to be running Ubuntu. Do a search for
"ubuntu reset mysql password". Or, if you don't have any important data in your
installation of MySQL at this stage, just purge the install, and re-install it.


Cheers,
Tink
 
Old 09-03-2012, 04:24 PM   #3
southpointingchariot
Member
 
Registered: Sep 2012
Posts: 31

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Tinkster View Post
Hi, welcome to LQ!

Looking at your browser-icon you appear to be running Ubuntu. Do a search for
"ubuntu reset mysql password". Or, if you don't have any important data in your
installation of MySQL at this stage, just purge the install, and re-install it.


Cheers,
Tink
Thanks for your help! As I used tasksel, I'm not exactly sure what package actually contains MySQL. Is it "mysql-server"?

Also, you purge a package with "sudo apt-get purge <package>", correct?
 
Old 09-03-2012, 07:36 PM   #4
sag47
Senior Member
 
Registered: Sep 2009
Location: Raleigh, NC
Distribution: Ubuntu, PopOS, Raspbian
Posts: 1,899
Blog Entries: 36

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
There are a couple of ways to go about it. Remove the mysql database and let the service re-create one without a password.

Code:
service mysqld stop
cd /var/lib/mysql/
#make sure there are databases with ls
rm -rf *
service mysqld start
The better alternative is to simply reset the root password within MySQL (see first link on page).

The problem here is not with mysql me thinks though. As root run mysql, you should be able to get right in without changing anything. LAMPP is apparently attempting to access mysql with a password which fails even when there is no password.

Since you're on Ubuntu I would suggest rather than installing XaMPP or LAMPP to simply install the packages separate using what is available.

Code:
sudo apt-get install apache2 mysql mysql-server
You can modify the http files in /var/www/ and access mysql through port 3306 using a local mysql client (the "mysql" command). One word of warning, you should enable a firewall so that external machines on your local network can connect to MySQL. There's a well known security flaw that the root pword can easily be brute forced with a simple login loop (takes only a few seconds).

Last edited by sag47; 09-03-2012 at 07:45 PM.
 
Old 09-03-2012, 07:54 PM   #5
southpointingchariot
Member
 
Registered: Sep 2012
Posts: 31

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by sag47 View Post
There are a couple of ways to go about it. Remove the mysql database and let the service re-create one without a password.

Code:
service mysqld stop
cd /var/lib/mysql/
#make sure there are databases with ls
rm -rf *
service mysqld start
The better alternative is to simply reset the root password within MySQL (see first link on page).

The problem here is not with mysql me thinks though. As root run mysql, you should be able to get right in without changing anything. LAMPP is apparently attempting to access mysql with a password which fails even when there is no password.

Since you're on Ubuntu I would suggest rather than installing XaMPP or LAMPP to simply install the packages separate using what is available.

Code:
sudo apt-get install apache2 mysql mysql-server
You can modify the http files in /var/www/
Thanks for your help! I should probably clarify that I have never intentionally done anything with MySQL, and a complete newb newb about it at this point (this was in fact what I was attempting to do something about that sparked this whole saga).

Your first solution returned "mysqld: unrecognized service".

After examining the "Unix Systems" section of the link you suggested (http://dev.mysql.com/doc/refman/5.0/...rmissions.html), I am left with more questions. How do I figure out what user mysqld runs as? It's a personal computer, so its either me or root.

When attempting to install the programs as you suggested, I get "E: Unable to locate package mysql"

Sorry for the ignorance!
 
Old 09-03-2012, 08:03 PM   #6
sag47
Senior Member
 
Registered: Sep 2009
Location: Raleigh, NC
Distribution: Ubuntu, PopOS, Raspbian
Posts: 1,899
Blog Entries: 36

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
Apologies, I should double check the commands. Here, let's go through the process and you can follow along. Let's go into a root prompt but be very careful in there!
Code:
sudo su -
apt-cache search mysql | grep ^mysql
apt-get install mysql-server mysql-client
ls /etc/init.d | grep mysql
#note at this point you should see mysql
#you can invoke the service in one of two ways, by using /etc/init.d/mysql or with the following.
service mysql status
#start the mysql service if it is stopped
service mysql start
#now let's open mysql using the mysql client (it is a command)
mysql
#to quit mysql run the following
quit;
#we're now back at the shell
exit
#we're no longer logged in as root
You can do the same for apache or httpd (forget which it is called on Ubuntu). Are you running Ubuntu 12.04? If you're not sure you can do the following.
Code:
cat /etc/issue

Last edited by sag47; 09-03-2012 at 08:06 PM.
 
Old 09-03-2012, 08:10 PM   #7
southpointingchariot
Member
 
Registered: Sep 2012
Posts: 31

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by sag47 View Post
Apologies, I should double check the commands. Here, let's go through the process and you can follow along. Let's go into a root prompt but be very careful in there!
Code:
sudo su -
apt-cache search mysql | grep ^mysql
apt-get install mysql-server mysql-client
ls /etc/init.d | grep mysql
#note at this point you should see mysql
#you can invoke the service in one of two ways, by using /etc/init.d/mysql or with the following.
service mysql status
#start the mysql service if it is stopped
service mysql start
#now let's open mysql using the mysql client (it is a command)
mysql
#to quit mysql run the following
quit;
#we're now back at the shell
exit
#we're no longer logged in as root
You can do the same for apache or httpd (forget which it is called on Ubuntu). Are you running Ubuntu 12.04? If you're not sure you can do the following.
Code:
cat /etc/issue
I am on 12.04. When following your instructions, I get "ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)" when attempting to open the client.

When I said I did some damage, I wasn't joking . This is easily my most embarrassing technical story. I broke every bloody rule. Thank you again for your help!
 
Old 09-03-2012, 08:11 PM   #8
sag47
Senior Member
 
Registered: Sep 2009
Location: Raleigh, NC
Distribution: Ubuntu, PopOS, Raspbian
Posts: 1,899
Blog Entries: 36

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
What does service mysql status say? Also, do you remember the password you set on it, if at all?
 
Old 09-03-2012, 08:14 PM   #9
southpointingchariot
Member
 
Registered: Sep 2012
Posts: 31

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by sag47 View Post
What does service mysql status say? Also, do you remember the password you set on it, if at all?
"mysql start/running, process 1062"

Alas, I do not - partially because I've gone through several intersecting set ups.
 
Old 09-03-2012, 08:15 PM   #10
sag47
Senior Member
 
Registered: Sep 2009
Location: Raleigh, NC
Distribution: Ubuntu, PopOS, Raspbian
Posts: 1,899
Blog Entries: 36

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
Is it okay if we blow away the old database? Or would you rather keep it around and simply reset the password? Also if you just so happen to remember the password you can log into mysql using a password.

Code:
mysql -u root -p
See "man mysql" for more information.

Last edited by sag47; 09-03-2012 at 08:16 PM.
 
Old 09-03-2012, 08:16 PM   #11
southpointingchariot
Member
 
Registered: Sep 2012
Posts: 31

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by sag47 View Post
Is it okay if we blow away the old database? Or would you rather keep it around and simply reset the password?
No problem - I'm totally open to a hard reset of the whole business. Nothing has been done with it so far on this machine.
 
Old 09-03-2012, 08:19 PM   #12
sag47
Senior Member
 
Registered: Sep 2009
Location: Raleigh, NC
Distribution: Ubuntu, PopOS, Raspbian
Posts: 1,899
Blog Entries: 36

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
Okay let's blow it away.
Code:
sudo su -
service mysql stop
cd /var/lib/mysql/
#make sure there are databases with ls
rm -rf *
#now there should be no databases
service mysql start
#now there should be a default database again, use ls to see
Remember, you shouldn't take any forum member's advice without understanding the commands you're running. If there's a command you don't understand, ask, if there are command options which you're not familiar then look at the man page for that command.

e.g. man rm, look at the options -r and -f to see what they do.

Once you have a new database you should be able to open the database using the "mysql" client command.

SAM

Last edited by sag47; 09-03-2012 at 08:20 PM.
 
Old 09-03-2012, 08:26 PM   #13
southpointingchariot
Member
 
Registered: Sep 2012
Posts: 31

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by sag47 View Post
Okay let's blow it away.
Code:
sudo su -
service mysql stop
cd /var/lib/mysql/
#make sure there are databases with ls
rm -rf *
#now there should be no databases
service mysql start
#now there should be a default database again, use ls to see
Remember, you shouldn't take any forum member's advice without understanding the commands you're running. If there's a command you don't understand, ask, if there are command options which you're not familiar then look at the man page for that command.

e.g. man rm, look at the options -r and -f to see what they do.

Once you have a new database you should be able to open the database using the "mysql" client command.

SAM
I'm familiar with -rf and such, but your advice is very good .

On that line of thought, I'm not sure if there are any databases (what extension would they be?). ls returns:
debian-5.5.flag ib_logfile1 performance_schema
ibdata1 mysql test
ib_logfile0 mysql_upgrade_info
 
Old 09-03-2012, 08:35 PM   #14
sag47
Senior Member
 
Registered: Sep 2009
Location: Raleigh, NC
Distribution: Ubuntu, PopOS, Raspbian
Posts: 1,899
Blog Entries: 36

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
If there's anything then you're good. Just run the following command,
Code:
mysql -u root
You should see a mysql> prompt now. If you want to change the password for the root user (highly recommended) then run the following command,
Code:
#first time only
mysqladmin -u root password

#if you ever want to change the password then you'll need to connect by using the password option
#since you would have already had a password.
mysqladmin -u root -p password
When ever you're working in a CMS it's best to not allow it to use the root mysql user. Create a database, create a user, and then grant that user access to the database. Here's an example (all mysql code).
Code:
CREATE USER 'mycms'@'localhost' IDENTIFIED BY 'mycms';
CREATE DATABASE mycms;
GRANT ALL PRIVILEGES TO mycms.* TO 'mycms'@'localhost' IDENTIFIED BY 'mycms';
The capitalized sql is not case sensitive but I used it to emphasize the difference between commands and arguments.

We created a user mycms who is identified by the password mycms. Then we granted access to the database mycms to the user mycms. Now quit; mysql and then log in as your new mycms user. You should only be able to see the database it has privileges to.
Code:
#Note: mysql -u [user] -p[password] [database]
mysql -u mycms -pmycms mycms
#you're now logged into mysql so let's see the databases.
show databases;
By having a user only allowed to access it's own database you can install multiple databases and users who won't be able to touch each others data. This comes in handy when you're running more than one CMS or if you're running more than *just* a CMS.

Last edited by sag47; 09-03-2012 at 08:37 PM.
 
1 members found this post helpful.
Old 09-03-2012, 08:45 PM   #15
southpointingchariot
Member
 
Registered: Sep 2012
Posts: 31

Original Poster
Rep: Reputation: Disabled
Alas, we have a problem on the earlier step. When I run "service mysql start", I get "start: Job failed to start"
 
  


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
LXer: How To Install LAMP Server in Ubuntu Server 12.04 LTS LXer Syndicated Linux News 0 05-20-2012 12:45 AM
Centos LAMP Server with unidentified script causing server to port scan ZS- Linux - Security 48 01-30-2011 07:27 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:22 AM.

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