For over six years now, I've been studying mathematics on my own in my spare time  working my way through books, exercises, and online courses. In this post I'll share what books and resources I've worked through and recommend and also tips for anyone who wants to go on a similar adventure.
Selfstudying mathematics is hard  it's an emotional journey as much as an intellectual one and it's the kind of journey I imagine many people start but then drop off after a few months. So I also share (at the end) the practices and mindset that have for me allowed this hobby to continue through the inevitable ups and downs of life (raising two young boys, working at a startup, and moving states!)
How it all began for me
I used to love mathematics. Though I ended up getting an engineering degree and my career is in software development, I had initially wanted to study maths at university. But the reality is, that's a very tough road to take in life  the academic world is, generally speaking, a quite tortuous path with low pay, long hours, and rife with burnout. So I took the more pragmatic path and as the years went by never really found the time to reconnect with math. That was until about six years ago when I came across Robert Ghrist's online course Calculus: Single Variable (at the time I took it, it was just a Coursera course but now it's freely available on YouTube). Roughly 12 weeks and many filled notebooks later, I had reignited my interest in math and felt energized and excited.
Robert, if you read this: thanks for being such an inspiring teacher.
Why learn mathematics?
Growing up I always loved puzzles and problem solving. I would spend hours working my way through puzzle books, solving riddles, and generally latching on to anything that gives you that little dopamine hit.
If you're similar, mathematics might just be for you. Mathematics is hard. Seriously hard. And then suddenly, what was hard is easy, trivial, and you continue your ascent on to the next hard problem. It deeply rewards patience, persistence, and creativity and is a highly engaging activity  it's just you quietly working away, breaking down seemingly impossible problems and making them possible. I can't say enough how deeply satisfying and personally enriching it is to make the impossible, possible through your own hard work and ingenuity.
One thing many people don't know as well is that the mathematics you learn at most high schools is actually quite different from what you're exposed to at the university level. The focus turns from being about rote computation to logic, deduction, and reasoning. A great quote I read once is that for most of us, when we learn mathematics at school, we learn how to play a couple of notes on a piano. But at university, we learn how to write and play music.
Picking the right books and courses for selflearning
As a selflearner, it's critical to pick books with exercises and solutions. At some point later on you can swap to books without exercises and/or solutions, but in the beginning you need that feedback to be able to learn from your mistakes and move forward when you're stuck.
The books you pick as a selflearner are also sometimes different from what you would work use if you were engaged in fulltime study at a university. Personally, I lean more towards books with better exposition, motivation, and examples. In a university setting, lecturers can provide that exposition and complement missing parts of books they assign for courses, but when you're on your own those missing bits can be critical to understanding.
I recommend avoiding the Kindle copies of most books and always opting for print. Very few math books have converted to digital formats well and so typically contain many formatting and display errors. Incidentally, this is often the main source for bad reviews of some excellent books on Amazon.
I'd be remiss as well if I didn't mention the publisher Dover. Dover is a well known publisher in the math community, often publishing older books at fantastically low prices. Some of the Dover books are absolutely brilliant classics  I own many and have made sure to make note of them in my recommendations below. If you don't have a big budget for learning, go for the Dover books first.
In several places I also recommend courses from MIT OpenCourseware. These courses are completely free and often have full recorded video lectures, exam papers with solutions, etc. If you like learning by video instruction and find at various points that you're getting a bit lost in a book, try looking up an appropriate course on MIT OpenCourseware and seeing if that helps get you unstuck.
Pretty much all my books I recommend below focus on undergraduate level math, with an emphasis on pure vs applied. That's just because that's the level that I'm at and also the kind of maths I like the most!
And also, just a final note that the order of books I recommend below is not exactly the order I worked through them  rather, it's the order I think they should be worked through. Sometimes I picked up a book that was too hard and had to double back and wait until I was ready. And some books have only just come out recently as well (eg. Ivan Savov's "No BS" books) so weren't available to me when I was at that stage of learning. In short, you get to benefit from my hindsight and missteps along the way.
Alright, let's jump in to the recommendations!
Foundations
I'm going to assume a highschool level of maths is where you last leftoff and that it's been some time since then that you've last done any maths. To get going, there's a couple of books I recommend:
The Art of Problem Solving, Vol 1 & 2 (with solutions manuals)  Lehoczky and Rusczyk
The Art of Problem Solving books are wonderful starter books. They're oriented heavily towards exercises and problem solving and are fantastic books to get you off to a start actually doing maths and also doing it in a way that's not just repetitive and boring. Depending on your level of mathematical maturity, you may only want to work through volume 1 and come back to volume 2 after you've worked through a proofs book first though (the second volume has many more questions involving writing proofs which you may not yet be comfortable enough to do at this stage). Volume 2 has many excellent exercises though, so don't skip it!
No bullshit guide to math and physics  Savov
If your calculus is a little rusty or you never really understood it in highschool, I recommend working through this book. It's compact, free of longwinded explanations, and contains lots of exercises (with solutions). This book teaches calculus in a contextually motivated way by teaching it alongside mechanics, which is how I think calculus should always be taught initially (I almost recommended Kline's Calculus: An Intuitive and Physical Approach here instead, as a book I also very much like, but Kline's book is just so thick and verbose. If you do like that additional exposition, you may want to consider this book as an alternative).
Also, of course I must mention the course that started it all for me, Calculus: Single Variable. It appears Coursera has now broken the course up into several parts and as I mentioned you can also find the full lessons on YouTube. Work through either this or Savov's book  depending on whether you prefer learning from books or online courses.
A historical (and motivated) perspective
I think it's useful early on in the learning journey to have a broad map of where math has been, what has motivated its development to date, and also where it's going.
Mathematics for the Nonmathematician (Dover)  Kline
For a historical view, I highly recommend reading through Kline's Mathematics for the Nonmathematician. It contains a small handful of exercises, but they're not the main focus  this is one of the few math books I recommend that you can just leisurely read.
Concepts of Modern Mathematics (Dover)  Stewart
While Kline provides the historical perspective, Stewart will provide you with the modern perspective. This is one of the first math books I read that genuinely made me excited and deeply want to understand topology  up until then, I was only somewhat dimly aware of the subject and thought it was a bit silly. Like the Kline book, this book also has no exercises  but for me it was a springboard and motivator to open other related books and dig in and do some handson math.
Mathematics and Its History  Stillwell
I consider Mathematics and Its History to be somewhat optional at this point, but I want to mention it because it's so darn good. If you read through Kline's and Stewart's books and thought "You know what, these ideas are really nice but I'd love to go more handson with them with some exercises" then this book is for you. Want to try to do some gentle introductory exercises from fields like noneuclidean geometry, group theory, and topology, not just idly read about them? This book might be for you.
BBC's A Brief History of Mathematics (Podcast)  du Sautoy
If you prefer listening over reading, I recommend listening to the 10part podcast A Brief History of Mathematics that focuses on the interesting lives and personalities of some of the driving historical forces in mathematics (Galois, Gauss, Cantor, Ramanujan, etc.).
Proofs and mathematical logic
For many, your first proof book is where everything clicks and you begin to understand that there is more to math than just calculation. For this reason, many people have very strong feelings about their favourite proofs book and there are indeed several that are quite good. But my favourite of all of them is:
An Introduction to Mathematical Reasoning  Eccles
I think what I love most about An Introduction to Mathematical Reasoning is how it successfully pairs explanation with exercises, which is a recurring theme in books that I tend to gravitate to. Good exercises are an extension of the teaching journey  they tell their own story and have progression and meaning. And at the time I worked through this book, the difficulty was just right. A good chunk of the book is occupied with applying the proof techniques you learn to different domains like set theory, combinatorics, and number theory, which is also something that personally resonated with me.
Book of Proof  Hammack
Book of Proof is a nice little proofs book. It's not too long and has a good number of exercises. If you're looking for a gentler introduction to proofs this is the one to go for. For the edition I used, it contained solutions for every second problem with full solutions available on the author's personal website, which I believe is still the case today.
Calculus/Real Analysis
Calculus  Spivak
Spivak's Calculus is the among the best maths book I have ever worked through but don't be fooled by the name  this is an introductory book to real analysis and is very different from the Calculus books mentioned earlier which emphasize computation. The emphasis for this book is on building up the foundations step by step for single variable calculus (starting from the construction of real numbers). It is a wonderfully coherent and realized book and what's also great about it is once again the exercises complement and expand on the content so well. Speaking of the exercises, some are seriously hard. This book took me about 6 months to work through because at the time I was still committed to solving every single exercise on my own. I almost burned out and I discuss what I learned from that experience coming up.
Everybody should own this book.
Calculus  Apostol
Spivak's book can be genuinely too hard for some people at this stage. For that reason, there are two other books I'm happy to recommend as alternatives.
The first is Apostol's Calculus. Apostol proceeds at a more leisurely pace compared to Spivak, and is happy to spend time building up your intuition with examples and geometric arguments before diving in to more rigorous proofs. Interestingly enough, the book also goes a fairly long way in introducing linear algebra in the final few chapters. I do like as well that this book introduces integration before differentiation, which you'll know if you read through Kline's historical book, is more historically accurate.
One thing to note is this book can be quite hard to find and unfortunately the edition I have has some weird print quality issues. Your mileage may vary.
Introduction to Analysis  Mattuck
The second introductory analysis book I'm happy to recommend is Mattuck's Introduction to Analysis. As with Spivak, this book mostly focuses on realvalued functions of a single variable and only in the last few chapters goes beyond. Mattuck makes clear in the introduction that this book was written for those struggling with analysis and less confident with proof techniques and I think it succeeds really well in what it set out to do. If you're struggling with Spivak, pick this book up.
Linear Algebra
For Linear Algebra, I can suggest two different learning paths. If you prefer to work through books only, I recommend working through Savov and Axler for both the applied and pure views of linear algebra. However, if you're comfortable with video instruction, I really like Gilbert Strang's Linear Algebra material (both the book and the online course).
Starting with Savov and Axler:
No bullshit guide to linear algebra  Savov
No bullshit guide to linear algebra is a book that has only come out quite recently, and it's a book I read only after already making my way through more advanced texts. That necessarily changes your perspective, but nonetheless I still think this is an excellent book for a first introduction to linear algebra. One quality of the book I really appreciated was the healthy coverage of applications in the final few chapters  looking at the application of linear algebra to problems in cryptography, fourier analysis, probability, etc.
Linear Algebra Done Right  Axler
Linear Algebra Done Right is a quite well known book, famous for its nonstandard treatment of determinants, only really introducing them towards the end of the book. Incidentally, this is what the "Done Right" in the title refers to: Axler has a bone to pick with determinants and doesn't hide it. It's a puremath proofs focused book with nothing in the way of applications, which is also why I suggest pairing this book with Savov's which is more applied/computational. The proofs in the book are excellent and are a model for clarity and simplicity  working through this book really helped me build up a strong foundational intuition for linear algebra. The book unfortunately does not come with solutions to the exercises, but many can be found online.
Introduction to Linear Algebra and MIT OCW Linear Algebra  Strang
Here I treat both the book and the course as one, because they complement each other so well. What that does mean however is that you'll often find yourself jumping back and forwards between the book and the videos  for some people that's going to be a plus and enhance the learning experience (in many ways, it's much like it would be if you attended MIT in person) while for others that's a big detracting point. I'll leave it for you to decide which is best for you. In terms of the material, the focus is mostly on the applied side of things but still managing to touch on the theory in places. The exercises are quite good, plus you also get access to the MIT exams (with solutions).
Coding the Matrix: Linear Algebra through Applications to Computer Science  Klein
If you're a software developer like me, I wholeheartedly recommend that you pick up Coding the Matrix. I originally learned about this book through a course on Coursera but never took the online course and instead went straight for the book. The emphasis of the book is on programming (with Python), applying techniques from linear algebra to applied problems such as compression, image manipulation, machine learning, etc. It's the kind of book that I think works best if you've already had some introduction to linear algebra by working through any of the above above recommended books, giving your theoretical foundations a really strong applied grounding.
A brief interlude to talk about study, exercises, and taming the completionist inside you
Ok, let me take a moment to share some hardwon advice. When it comes to solving exercises as you work through these books, the completionist mindset will destroy you. When I first set out on my adventure, I would refuse to move forward in a book until I had solved every problem. This worked up to a point...and that point was when I met Spivak and had to finally concede defeat.
It's hard to put a formal rule on how long you should spend on any given exercise before "giving up" and looking at the solution. I would say a lower bound should be maybe 20 minutes or so. But the upper bound? I don't know. For some problems, it can be fruitful and productive to spend days (weeks even?) thinking about them provided you're making some kind of incremental progress or still have tricks in your bag you want to apply.
For me personally, I spend around 10 hours most weeks doing math and I've had brief bursts where I've done as much as 30hrs/week when I'm between contracts, etc. What that does mean though is that one hard exercise can completely block your progress for weeks if you let it, and I'll say right now, when that does happen, it can be quite demoralizing.
Ultimately, my advice is to let your intuition and energy levels guide you  do you have the energy to chase this really hard problem down or are you in the mood for just learning the answer now? If you just want the answer now so you can move forward, look it up! There's no penalties here. You didn't lose.
I know it feels unnatural to not set hard rules around how long you should spend on a given problem, but remember that ultimately you're optimizing for your enjoyment (that's why you're doing this, right?) and long term consistency.
You will do yourself a disservice (in maths, and in life) if you burn out hot and fast.
Multivariable Calculus
MIT OCW Multivariable Calculus
The MIT OCW Multivariable Calculus course is the best resource I've found for getting comfortable with multivariable calculus. I don't really know of any good books covering this subject (no, please don't say Stewart) and I found the MIT course to be really enjoyable. Good collection of problems and worked solutions, clear material and lectures. And if I'm honest, as a selflearner who went to a good but not great university, there is also something quite satisfying about "sitting" an exam from MIT in the same conditions as an MIT student would experience and completely acing the exam.
Differential Equations
Ordinary Differential Equations (Dover)  Tenenbaum and Pollard
ODEs get a bit of a bad rap for being a quite boring subject, and I think many people view the process of learning about differential equations as being about internalizing an almost random collection of "tricks" to solve certain ODE forms. But it doesn't have to be that way, and I learned that from working through this book. While this book leans heavily into the applied/computational side of mathematics, it also does a great job complementing the examples and exercises with theory. It does feel a bit dated at times (it was written in 1985) and could probably benefit in certain places with some visual aids, but if you're comfortable with Python and plotting/graphical libraries you can make it up yourself as you go along. Overall, the book moves along at a fairly gentle pace  you're unlikely to get stuck as you work through the book as long as you're diligent, all the exercises have solutions, and being a Dover book, it's really cheap!
Analysis
Principles of Mathematical Analysis  Rudin
Rudin's Principles of Mathematical Analysis, also affectionately known as Baby Rudin, is a difficult, serious book but if you made your way through Spivak and all the books I've shared so far, you've got all the tools you need to succeed to make it through this. Occasionally you'll see this recommended as the first book people should learn analysis from, but I think that's a big mistake for us selflearners: it's dry, contains little in the way of motivation/exposition and has quite a few "fill in the blanks" moments.
Note that although this book does not have any official solutions, there is a reddit community that has been working through the book, crowdsourcing and documenting solutions. The community is at https://www.reddit.com/r/babyrudin/ and the crowdsourced solutions document can be found here.
Algebra
A Book of Abstract Algebra (Dover)  Pinter
I'm really excited to recommend Pinter's A Book of Abstract Algebra and the truth is if the subject of Abstract Algebra is of real interest to you, this is the kind of book you can pick up and work through very early on  as early as after finishing your first book of proofs (and if you're clever, even before that). The chapters are quite short, with each chapter accompanied by a pretty hefty set of exercises which expand on the content. The book covers all the usual suspects: groups, rings, etc. and ultimately builds its way up to Galois Theory. One important thing to note is the book only contains solutions to selected exercises but the exercises are not too hard, so this shouldn't be too much of a problem.
One funny sidenote: I've heard it said on many occasions that mathematicians typically fall into one of two camps: those who like algebra (algebraists), and those who like analysis (analysts). It's even been observed that analysts tend to eat corn in spirals, while algebraists in rows. After now getting your first taste of algebra, which camp do you think you're in and does the corn theory hold true?
Abstract Algebra  Dummit and Foote
While Pinter's A Book of Abstract Algebra is excellent, it only covers a small sliver of topics from the field of abstract algebra. By contrast, Abstract Algebra is massive, and covers a lot of ground. You could almost affectionately call it a reference, but at the same time it also has a lot of those same qualities that make it excellent for selfstudy  lots of examples and exercises, good motivation and descriptions, etc. Just a note though that it does not come with solutions to the exercises, but given its popularity, it's quite easy to find them online.
To reiterate, this is a big book and I haven't myself worked my way through it entirely, but rather just picked it up now and then and absorbed small bits and pieces at a time...in many ways treating it like a reference instead of something to work through from start to finish.
If you can, buy the hardcover. Books this big don't fare as well as paperback.
Topology
Topology  Munkres
Focusing on point set Topology, Munkres' Topology is widely considered to be one of the best introductory books in the field. Topology is a quite difficult subject to grasp and it took me several attempts to get going  I admit to feeling much like Hitler in Hitler learns topology for a very long time until finally things started to click. Part 2 of the book contains a nice introduction to algebraic topology but I'll admit now at the time I got to this material I was already struggling a bit and have never revisited the material.
Introduction to Topology (Dover)  Mendelson
This was the book that really helped me get Topology. If you're finding Munkres a bit difficult to get going, this book is both cheaper and has a bit more exposition  there's a lot more handholding and the book takes its time to help you build up the intuition for why things work. In my opinion, this is the better book of the two for selflearners.
Number Theory
Elementary Number Theory  Jones
Elementary Number Theory is a great book for anyone who wants to jump in to number theory first and may have skipped some of the previously mentioned books on algebra, as it assumes very little prior knowledge. This was certainly the case for me, where I worked through this book shortly after my first proofs book. In terms of difficulty, it was perfect for me at the time, but on reflection now it might be too easy for some. If that's the case, take a look at An Introduction to the Theory of Numbers which I think would be the next best step up in difficulty and maturity.
Number Theory (Dover)  Andrews
George Andrews is one of the leading experts in the field of partitions and this book provides an excellent first introduction to the field along with a good selection of other topics (with a combinatorial focus). It's quite a short book, but manages to pack a lot in and has a great selection of exercises (with solutions to selected exercises). If you've ever heard the "RogersRamanujan identities" and wanted to learn more, this book is the perfect study companion.
Probability
Introduction to Probability, Statistics, and Random Processes  PishroNik
While focusing more on the applied side of probability and statistics (this book doesn't go anywhere near measure theory), this book ended up being a really pleasant surprise for me in a field that I wasn't particularly interested in and have always found a bit dry. It also doesn't really assume much in the way of prior knowledge except for a little multivariable calculus and linear algebra, making it very approachable. I think engineers working in the fields of machine learning and data science in particular would really benefit from working through this book.
Other
What follows is a collection of books and resources I also highly recommend, but somewhat off the beaten path and chosen by me more for personal interest.
What Is Mathematics?  Courant and Robbins
What Is Mathematics is a classic and it's one that I thoroughly enjoyed reading...eventually. Why eventually? While it's claimed to be an "elementary" book for the "beginner", in truth, if you gave this book to any but the most gifted highschool graduate it would absolutely crush them within the first ~20 pages. And such was the case with me, where I picked this book up and tried to work through it very early on in my learning journey. Unless you're brilliant (and I surely am not), I really would recommend only tackling this book after working through a proofs book and some of the foundation books I recommended earlier. The book itself is quite broad in the subject matter it covers  number theory, geometric constructions, projective geometry, topology, and finally on to calculus. It's actually a really playful and fun book and manages really well to avoid getting bogged down too much in any one area. I highly recommend it...just make sure you don't start it before you're ready.
Naive Set Theory (Dover)  Halmos
Naive Set Theory gets right to the heart of the settheoretic underpinnings of mathematics and does it extremely well. It is an extremely readable book, and in my opinion Halmos was one of the best mathematical expositors ever (interesting aside: Halmos invented the "iff" notation for that wonderful phrase "if and only if" and also the ∎ notation to signify the end of a proof!). It contains only a small handful of exercises. This book was my first exposure to proper set theory and I really enjoyed it.
The CauchySchwarz Master Class  Steele
You can almost think of The CauchySchwarz Master Class as an exercises/problem solving book for inequalities...as I worked through it I couldn't help but think this book would basically be the perfect bootcamp for dealing with tricky inequalities in a competitive math setting. It's got that quality of books like Polya's How to Solve It and others in that its always prodding you to think creatively and work the problems. And working through it, you also come to appreciate just how damn versatile the CauchySchwarz inequality is!
Prime Numbers and the Riemann Hypothesis  Mazur and Stein
I'm currently reading this book right now!
Connecting with the broader math community
At least for me, studying mathematics has been a fairly isolated experience and I've never really found a good community to participate in. There are a couple of communities I'm aware of though, and of these, /r/math and the AoPS Community seem to be the most active. There's also the Math StackExchange, which is very active, but I find it hard to classify that as a community.
I also really like Grant Sanderson's 3Blue1Brown YouTube Channel  he has a lot of excellent general interest math videos with just the right amount of rigor.
What's next
There's a couple of books I've heard great things about that I'm really interested in reading next. They are (in no specific order):
Mathematics: Its Content, Methods and Meaning  I actually own the Kindle edition of this but as with many math books, it has not been converted to digital format well. I'm really looking forward to picking up the print copy and having a go at this.
Visual Complex Analysis  Some chapters in the TOC look quite familiar to me, and others I have no idea about...which is quite exciting!
Introductory Functional Analysis with Applications  I've heard this is one of the best introductory books for functional analysis.
Some parting advice
I'm currently 35 years old, and while studying mathematics have had two wonderful kids and cofounded a startup. Suffice to say, life has been busy. So I wanted to offer some more general advice for anyone who also wants to study math while also staying sane. Here is what has helped me:

Exercise. It turns out that you're not just a brain in a tank and the mindbody connection has an immense impact on your daily happiness and wellbeing. Exercise every day.

Take regular breaks and go for walks. Seemingly intractable problems have a surprising way becoming tractable after a long walk. Sunshine also has a wonderful effect on improving your overall mood and helping you sleep better.

Alternate between easier and harder content. One way you're sure to burn out is if you are always pushing, without periods of rest. Make sure you follow up hard books with easier, almost routine, books. Sometimes it can even be beneficial to work on two books at once  one easy, one hard. Make sure to pepper in little easy wins everywhere in between the big meaty hard problems. Always follow up "failure" (ie. this problem is too hard, I give up) with "success".

Spend time with friends and family. Selfstudying maths can be a bit isolating, but ultimately we're wired to be social creatures. Don't neglect your friends and family. Invest in good relationships with people you love to be around.